@@ -92,6 +92,31 @@ void testQualifiedObjectPassedAsInterfaceShouldAddIssue() {
9292 .verifyIssues ();
9393 }
9494
95+ @ Test
96+ void testComplexQualifiedObjectPassedAsInterfaceShouldAddIssue () {
97+ CheckVerifier .newVerifier ()
98+ .withCheck (new ObjectPassedAsInterfaceCheck ())
99+ .onFile (
100+ new DelphiTestUnitBuilder ()
101+ .appendDecl ("type" )
102+ .appendDecl (" TFoo = class(TInterfacedObject, IInterface)" )
103+ .appendDecl (" end;" )
104+ .appendDecl (" IBar = interface" )
105+ .appendDecl (" property Foo: TFoo;" )
106+ .appendDecl (" end;" )
107+ .appendDecl (" TBar = class(TInterfacedObject, IBar)" )
108+ .appendDecl (" end;" )
109+ .appendDecl ("procedure DoThing(Obj: IInterface);" )
110+ .appendImpl ("procedure Test;" )
111+ .appendImpl ("var" )
112+ .appendImpl (" Intfs: TArray<IBar>;" )
113+ .appendImpl ("begin" )
114+ .appendImpl (" Intfs := [TBar.Create];" )
115+ .appendImpl (" DoThing(Intfs[0].Foo); // Noncompliant" )
116+ .appendImpl ("end;" ))
117+ .verifyIssues ();
118+ }
119+
95120 @ Test
96121 void testInterfacePassedAsInterfaceShouldNotAddIssue () {
97122 CheckVerifier .newVerifier ()
@@ -130,6 +155,27 @@ void testQualifiedInterfacePassedAsInterfaceShouldNotAddIssue() {
130155 .verifyNoIssues ();
131156 }
132157
158+ @ Test
159+ void testComplexQualifiedInterfacePassedAsInterfaceShouldNotAddIssue () {
160+ CheckVerifier .newVerifier ()
161+ .withCheck (new ObjectPassedAsInterfaceCheck ())
162+ .onFile (
163+ new DelphiTestUnitBuilder ()
164+ .appendDecl ("type" )
165+ .appendDecl (" TFoo = class" )
166+ .appendDecl (" property Intf: IInterface;" )
167+ .appendDecl (" end;" )
168+ .appendDecl ("procedure DoThing(Intf: IInterface);" )
169+ .appendImpl ("procedure Test;" )
170+ .appendImpl ("var" )
171+ .appendImpl (" Foos: TArray<TFoo>;" )
172+ .appendImpl ("begin" )
173+ .appendImpl (" Foos := [TFoo.Create];" )
174+ .appendImpl (" DoThing(Foos[0].Intf);" )
175+ .appendImpl ("end;" ))
176+ .verifyNoIssues ();
177+ }
178+
133179 @ Test
134180 void testObjectCastToInterfaceShouldNotAddIssue () {
135181 CheckVerifier .newVerifier ()
0 commit comments