Skip to content

Commit e352a4b

Browse files
committed
Note that parameterizations of local classes are themselves local
Previously `LocalClass` itself would match `.isLocal()` whereas `LocalClass<Param>` would not. Rather than require each individual user to check for `.getSourceDeclaration().isLocal()`, let's note that the specializations themselves are local.
1 parent d912a98 commit e352a4b

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)