Fix handling of reference types
This commit is contained in:
2 files changed
+14
-3
No files matched your search
+6
-1
@@ -1048,7 +1048,12 @@ public final class ConstructorCallsOverridableMethodRule extends AbstractJavaRul
|
||||
if (type.getChild(0) instanceof ASTPrimitiveType) {
|
||||
parameterTypes.add(type.getChild(0).getImage());
|
||||
} else if (type.getChild(0) instanceof ASTReferenceType) {
|
||||
parameterTypes.add("ref");
|
||||
JavaTypeDefinition typeDefinition = type.getTypeDefinition();
|
||||
if (typeDefinition != null) {
|
||||
parameterTypes.add(typeDefinition.getType().getName());
|
||||
} else {
|
||||
parameterTypes.add("ref");
|
||||
}
|
||||
} else {
|
||||
parameterTypes.add("<unknown>");
|
||||
}
|
||||
|
||||
+8
-2
@@ -322,8 +322,8 @@ import java.lang.annotation.*;
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>[java] ConstructorCallsOverridableMethod should consider method calls with var access #4099</description>
|
||||
<expected-problems>2</expected-problems>
|
||||
<expected-linenumbers>4,11</expected-linenumbers>
|
||||
<expected-problems>3</expected-problems>
|
||||
<expected-linenumbers>4,11,18</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
class Foo1 {
|
||||
final boolean tag = true;
|
||||
@@ -340,6 +340,12 @@ class Foo2 {
|
||||
public void bar(boolean b) {}
|
||||
}
|
||||
|
||||
class Foo3 {
|
||||
public Foo3(String arg) {
|
||||
bar(arg); // should report a warning at this line
|
||||
}
|
||||
public void bar(String s) {}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
Reference in new issue
Block a user