Skip to content

Commit b926bc9

Browse files
committed
Fix and add test for java/subtle-inherited-call involving inheritence from generic types
1 parent da04673 commit b926bc9

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

java/ql/src/Violations of Best Practice/Naming Conventions/AmbiguousOuterSuper.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ predicate callToInheritedMethod(RefType lexicalScope, MethodAccess ma, string si
2727
not ma.getMethod().isStatic() and
2828
not ma.hasQualifier() and
2929
ma.getEnclosingCallable().getDeclaringType() = lexicalScope and
30-
nestedSupertypePlus(lexicalScope).getAMethod() = ma.getMethod() and
30+
nestedSupertypePlus(lexicalScope).getAMethod() = ma.getMethod().getSourceDeclaration() and
3131
signature = ma.getMethod().getSignature()
3232
}
3333

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| GenericTest.java:14:7:14:9 | f(...) | A $@ is called instead of a $@. | GenericTest.class:0:0:0:0 | f | method declared in a superclass | GenericTest.java:9:8:9:8 | f | method with the same signature in an enclosing class |
2+
| Test.java:14:7:14:9 | f(...) | A $@ is called instead of a $@. | Test.java:3:8:3:8 | f | method declared in a superclass | Test.java:9:8:9:8 | f | method with the same signature in an enclosing class |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Violations of Best Practice/Naming Conventions/AmbiguousOuterSuper.ql
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class GenericTest<T> {
2+
3+
void f() { }
4+
5+
}
6+
7+
class Outer2 {
8+
9+
void f() { }
10+
11+
class Inner<T> extends GenericTest<T> {
12+
13+
public void test() {
14+
f();
15+
}
16+
17+
}
18+
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class Test {
2+
3+
void f() { }
4+
5+
}
6+
7+
class Outer {
8+
9+
void f() { }
10+
11+
class Inner extends Test {
12+
13+
public void test() {
14+
f();
15+
}
16+
17+
}
18+
19+
}

0 commit comments

Comments
 (0)