Skip to content

Commit 2a36744

Browse files
authored
Merge pull request #7552 from smowton/smowton/fix/local-parameterized-classes
Note that parameterizations of local classes are themselves local
2 parents b9ed8ed + e352a4b commit 2a36744

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

java/ql/lib/semmle/code/java/Type.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ class Interface extends ClassOrInterface, @interface {
905905
/** A class or interface. */
906906
class ClassOrInterface extends RefType, @classorinterface {
907907
/** Holds if this class or interface is local. */
908-
predicate isLocal() { isLocalClassOrInterface(this, _) }
908+
predicate isLocal() { isLocalClassOrInterface(this.getSourceDeclaration(), _) }
909909

910910
/** Holds if this class or interface is package protected, that is, neither public nor private nor protected. */
911911
predicate isPackageProtected() {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class Test {
2+
3+
public static void method() {
4+
5+
class GenericLocal<T> { }
6+
7+
GenericLocal<Integer> instantiated = new GenericLocal<>();
8+
9+
}
10+
11+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| Test$1GenericLocal.class:0:0:0:0 | GenericLocal<Integer> |
2+
| Test.java:5:11:5:22 | GenericLocal |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import java
2+
3+
from ClassOrInterface ci
4+
where
5+
ci.getSourceDeclaration().fromSource() and
6+
ci.isLocal()
7+
select ci

0 commit comments

Comments
 (0)