diff --git a/java/ql/lib/change-notes/2023-07-11-file-classes.md b/java/ql/lib/change-notes/2023-07-11-file-classes.md new file mode 100644 index 00000000000..b19fe60022b --- /dev/null +++ b/java/ql/lib/change-notes/2023-07-11-file-classes.md @@ -0,0 +1,4 @@ +--- +category: feature +--- +* A `Class.isFileClass()` predicate, to identify Kotlin file classes, has been added. diff --git a/java/ql/lib/semmle/code/java/Type.qll b/java/ql/lib/semmle/code/java/Type.qll index e8e9c2bf916..59338ed198e 100644 --- a/java/ql/lib/semmle/code/java/Type.qll +++ b/java/ql/lib/semmle/code/java/Type.qll @@ -709,6 +709,12 @@ class Class extends ClassOrInterface { ) } + /** + * Holds if this class is Kotlin "file class", e.g. the class FooKt + * for top-level entities in Foo.kt. + */ + predicate isFileClass() { file_class(this) } + override string getAPrimaryQlClass() { result = "Class" } }