File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed
main/java/au/com/integradev/delphi/checks
test/java/au/com/integradev/delphi/checks Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212- Inaccurate type comparisons between class and interface types, where class-to-class upcasts were
1313 not always preferred over class-to-interface upcasts.
14+ - False-positives around qualified name references in ` ObjectPassedAsInterface ` .
1415
1516## [ 1.18.0] - 2025-08-05
1617
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ private static boolean isVariableWithClassType(ExpressionNode expression) {
6767 return false ;
6868 }
6969
70- var declaration = ((NameReferenceNode ) maybeName ).getNameDeclaration ();
70+ var declaration = ((NameReferenceNode ) maybeName ).getLastName (). getNameDeclaration ();
7171 if (!(declaration instanceof VariableNameDeclaration )) {
7272 return false ;
7373 }
Original file line number Diff line number Diff line change @@ -67,6 +67,44 @@ void testObjectPassedAsInterfaceShouldAddIssue() {
6767 .verifyIssues ();
6868 }
6969
70+ @ Test
71+ void testInterfacePassedAsInterfaceShouldNotAddIssue () {
72+ CheckVerifier .newVerifier ()
73+ .withCheck (new ObjectPassedAsInterfaceCheck ())
74+ .onFile (
75+ new DelphiTestUnitBuilder ()
76+ .appendDecl ("procedure DoThing(Intf: IInterface);" )
77+ .appendImpl ("procedure Test;" )
78+ .appendImpl ("var" )
79+ .appendImpl (" Intf: IInterface;" )
80+ .appendImpl ("begin" )
81+ .appendImpl (" Intf := TInterfacedObject.Create;" )
82+ .appendImpl (" DoThing(Intf);" )
83+ .appendImpl ("end;" ))
84+ .verifyNoIssues ();
85+ }
86+
87+ @ Test
88+ void testQualifiedInterfacePassedAsInterfaceShouldNotAddIssue () {
89+ CheckVerifier .newVerifier ()
90+ .withCheck (new ObjectPassedAsInterfaceCheck ())
91+ .onFile (
92+ new DelphiTestUnitBuilder ()
93+ .appendDecl ("type" )
94+ .appendDecl (" TFoo = class" )
95+ .appendDecl (" property Intf: IInterface;" )
96+ .appendDecl (" end;" )
97+ .appendDecl ("procedure DoThing(Intf: IInterface);" )
98+ .appendImpl ("procedure Test;" )
99+ .appendImpl ("var" )
100+ .appendImpl (" Foo: TFoo;" )
101+ .appendImpl ("begin" )
102+ .appendImpl (" Foo := TFoo.Create;" )
103+ .appendImpl (" DoThing(Foo.Intf);" )
104+ .appendImpl ("end;" ))
105+ .verifyNoIssues ();
106+ }
107+
70108 @ Test
71109 void testObjectCastToInterfaceShouldNotAddIssue () {
72110 CheckVerifier .newVerifier ()
You can’t perform that action at this time.
0 commit comments