Skip to content

Commit b4c4a26

Browse files
committed
Element.hasChildElement: associate local classes specialisations with their unspecialised containing function
1 parent baaa063 commit b4c4a26

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ private predicate hasChildElement(Element parent, Element e) {
8282
enclInReftype(e, parent) and
8383
not e instanceof LocalClassOrInterface
8484
or
85-
e.(LocalClassOrInterface).getLocalTypeDeclStmt().getEnclosingCallable() = parent
85+
// Reasoning: any specialised instance of a local class is supposed to belong to the general
86+
// case of its enclosing method because we don't instantiate specialised variants of either generic
87+
// functions or function bodies, and therefore the local class cannot be specialised with respect
88+
// to its enclosing reftypes.
89+
e.(LocalClassOrInterface)
90+
.getSourceDeclaration()
91+
.(LocalClassOrInterface)
92+
.getLocalTypeDeclStmt()
93+
.getEnclosingCallable() = parent
8694
or
8795
not enclInReftype(e, _) and
8896
e.(Class).getCompilationUnit() = parent

0 commit comments

Comments
 (0)