diff --git a/java/ql/lib/semmle/code/java/Type.qll b/java/ql/lib/semmle/code/java/Type.qll index 1755442545d..1d8e0f81e97 100755 --- a/java/ql/lib/semmle/code/java/Type.qll +++ b/java/ql/lib/semmle/code/java/Type.qll @@ -905,7 +905,7 @@ class Interface extends ClassOrInterface, @interface { /** A class or interface. */ class ClassOrInterface extends RefType, @classorinterface { /** Holds if this class or interface is local. */ - predicate isLocal() { isLocalClassOrInterface(this, _) } + predicate isLocal() { isLocalClassOrInterface(this.getSourceDeclaration(), _) } /** Holds if this class or interface is package protected, that is, neither public nor private nor protected. */ predicate isPackageProtected() { diff --git a/java/ql/test/library-tests/localclasses/Test.java b/java/ql/test/library-tests/localclasses/Test.java new file mode 100644 index 00000000000..b1765b48439 --- /dev/null +++ b/java/ql/test/library-tests/localclasses/Test.java @@ -0,0 +1,11 @@ +public class Test { + + public static void method() { + + class GenericLocal { } + + GenericLocal instantiated = new GenericLocal<>(); + + } + +} diff --git a/java/ql/test/library-tests/localclasses/test.expected b/java/ql/test/library-tests/localclasses/test.expected new file mode 100644 index 00000000000..ca17141b224 --- /dev/null +++ b/java/ql/test/library-tests/localclasses/test.expected @@ -0,0 +1,2 @@ +| Test$1GenericLocal.class:0:0:0:0 | GenericLocal | +| Test.java:5:11:5:22 | GenericLocal | diff --git a/java/ql/test/library-tests/localclasses/test.ql b/java/ql/test/library-tests/localclasses/test.ql new file mode 100644 index 00000000000..1120279f1da --- /dev/null +++ b/java/ql/test/library-tests/localclasses/test.ql @@ -0,0 +1,7 @@ +import java + +from ClassOrInterface ci +where + ci.getSourceDeclaration().fromSource() and + ci.isLocal() +select ci