@@ -32,7 +32,7 @@ void testObjectPassedAsObjectShouldNotAddIssue() {
32
32
.appendDecl ("type" )
33
33
.appendDecl (" IFooIntf = interface" )
34
34
.appendDecl (" end;" )
35
- .appendDecl (" TFooImpl = class(TObject , IFooIntf)" )
35
+ .appendDecl (" TFooImpl = class(TInterfacedObject , IFooIntf)" )
36
36
.appendDecl (" end;" )
37
37
.appendDecl ("procedure DoThing(Obj: TFooImpl);" )
38
38
.appendImpl ("procedure Test;" )
@@ -54,7 +54,7 @@ void testObjectPassedAsInterfaceShouldAddIssue() {
54
54
.appendDecl ("type" )
55
55
.appendDecl (" IFooIntf = interface" )
56
56
.appendDecl (" end;" )
57
- .appendDecl (" TFooImpl = class(TObject , IFooIntf)" )
57
+ .appendDecl (" TFooImpl = class(TInterfacedObject , IFooIntf)" )
58
58
.appendDecl (" end;" )
59
59
.appendDecl ("procedure DoThing(Obj: IFooIntf);" )
60
60
.appendImpl ("procedure Test;" )
@@ -114,7 +114,7 @@ void testObjectCastToInterfaceShouldNotAddIssue() {
114
114
.appendDecl ("type" )
115
115
.appendDecl (" IFooIntf = interface" )
116
116
.appendDecl (" end;" )
117
- .appendDecl (" TFooImpl = class(TObject , IFooIntf)" )
117
+ .appendDecl (" TFooImpl = class(TInterfacedObject , IFooIntf)" )
118
118
.appendDecl (" end;" )
119
119
.appendDecl ("procedure DoThing(Obj: IFooIntf);" )
120
120
.appendImpl ("procedure Test;" )
@@ -136,7 +136,7 @@ void testNewObjectPassedAsInterfaceShouldNotAddIssue() {
136
136
.appendDecl ("type" )
137
137
.appendDecl (" IFooIntf = interface" )
138
138
.appendDecl (" end;" )
139
- .appendDecl (" TFooImpl = class(TObject , IFooIntf)" )
139
+ .appendDecl (" TFooImpl = class(TInterfacedObject , IFooIntf)" )
140
140
.appendDecl (" end;" )
141
141
.appendDecl ("procedure DoThing(Obj: IFooIntf);" )
142
142
.appendImpl ("procedure Test;" )
@@ -155,7 +155,7 @@ void testObjectPassedAsInterfaceToInheritedShouldAddIssue() {
155
155
.appendDecl ("type" )
156
156
.appendDecl (" IFooIntf = interface" )
157
157
.appendDecl (" end;" )
158
- .appendDecl (" TFooParent = class(TObject )" )
158
+ .appendDecl (" TFooParent = class(TInterfacedObject )" )
159
159
.appendDecl (" procedure Bar(Foo: IFooIntf); virtual;" )
160
160
.appendDecl (" end;" )
161
161
.appendDecl (" TFooImpl = class(TFooParent, IFooIntf)" )
@@ -170,4 +170,44 @@ void testObjectPassedAsInterfaceToInheritedShouldAddIssue() {
170
170
.appendImpl ("end;" ))
171
171
.verifyIssues ();
172
172
}
173
+
174
+ @ Test
175
+ void testExcludedTypePassedAsInterfaceShouldNotAddIssue () {
176
+ CheckVerifier .newVerifier ()
177
+ .withCheck (new ObjectPassedAsInterfaceCheck ())
178
+ .onFile (
179
+ new DelphiTestUnitBuilder ()
180
+ .appendDecl ("uses" )
181
+ .appendDecl (" System.Classes;" )
182
+ .appendDecl ("procedure DoThing(Obj: IInterface);" )
183
+ .appendImpl ("procedure Test(Obj: TComponent);" )
184
+ .appendImpl ("begin" )
185
+ .appendImpl (" DoThing(Obj);" )
186
+ .appendImpl ("end;" ))
187
+ .verifyNoIssues ();
188
+ }
189
+
190
+ @ Test
191
+ void testExcludedTypeDescendentPassedAsInterfaceShouldNotAddIssue () {
192
+ CheckVerifier .newVerifier ()
193
+ .withCheck (new ObjectPassedAsInterfaceCheck ())
194
+ .onFile (
195
+ new DelphiTestUnitBuilder ()
196
+ .appendDecl ("uses" )
197
+ .appendDecl (" System.Classes;" )
198
+ .appendDecl ("type" )
199
+ .appendDecl (" IFooIntf = interface" )
200
+ .appendDecl (" end;" )
201
+ .appendDecl (" TFooImpl = class(TComponent, IFooIntf)" )
202
+ .appendDecl (" end;" )
203
+ .appendDecl ("procedure DoThing(Obj: IFooIntf);" )
204
+ .appendImpl ("procedure Test;" )
205
+ .appendImpl ("var" )
206
+ .appendImpl (" Obj: TFooImpl;" )
207
+ .appendImpl ("begin" )
208
+ .appendImpl (" Obj := TFooImpl.Create;" )
209
+ .appendImpl (" DoThing(Obj);" )
210
+ .appendImpl ("end;" ))
211
+ .verifyNoIssues ();
212
+ }
173
213
}
0 commit comments