Skip to content

Commit 65a68f5

Browse files
authored
Merge pull request #13404 from aschackmull/java/functionalinterface-perf
Java: Improve join-order for FunctionalInterface.
2 parents a896be7 + dabb4dd commit 65a68f5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

+13-3
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,17 @@ private string getAPublicObjectMethodSignature() {
987987
)
988988
}
989989

990+
pragma[nomagic]
991+
private predicate interfaceInheritsOverridingNonAbstractMethod(Interface interface, Method m) {
992+
interface.inherits(m) and
993+
not m.isAbstract() and
994+
m.overrides(_)
995+
}
996+
997+
bindingset[m]
998+
pragma[inline_late]
999+
private Method getAnOverridden(Method m) { m.overrides(result) }
1000+
9901001
private Method getAnAbstractMethod(Interface interface) {
9911002
interface.inherits(result) and
9921003
result.isAbstract() and
@@ -995,9 +1006,8 @@ private Method getAnAbstractMethod(Interface interface) {
9951006
// Make sure that there is no other non-abstract method
9961007
// (e.g. `default`) which overrides the abstract one
9971008
not exists(Method m |
998-
interface.inherits(m) and
999-
not m.isAbstract() and
1000-
m.overrides(result)
1009+
interfaceInheritsOverridingNonAbstractMethod(interface, m) and
1010+
result = getAnOverridden(m)
10011011
)
10021012
}
10031013

0 commit comments

Comments
 (0)