mirror of
https://github.com/github/codeql.git
synced 2025-12-22 03:36:30 +01:00
Merge pull request #9876 from smowton/smowton/feature/interface-forwarding
Kotlin: implement default interface forwarding
This commit is contained in:
@@ -67,6 +67,8 @@ class Element extends @element, Top {
|
||||
i = 9 and result = "Forwarder for a @JvmOverloads-annotated function"
|
||||
or
|
||||
i = 10 and result = "Forwarder for Kotlin calls that need default arguments filling in"
|
||||
or
|
||||
i = 11 and result = "Forwarder for a Kotlin class inheriting an interface default method"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -77,7 +79,18 @@ class Element extends @element, Top {
|
||||
private predicate hasChildElement(Element parent, Element e) {
|
||||
cupackage(e, parent)
|
||||
or
|
||||
enclInReftype(e, parent)
|
||||
enclInReftype(e, parent) and
|
||||
not e instanceof LocalClassOrInterface
|
||||
or
|
||||
// Reasoning: any specialised instance of a local class is supposed to belong to the general
|
||||
// case of its enclosing method because we don't instantiate specialised variants of either generic
|
||||
// functions or function bodies, and therefore the local class cannot be specialised with respect
|
||||
// to its enclosing reftypes.
|
||||
e.(LocalClassOrInterface)
|
||||
.getSourceDeclaration()
|
||||
.(LocalClassOrInterface)
|
||||
.getLocalTypeDeclStmt()
|
||||
.getEnclosingCallable() = parent
|
||||
or
|
||||
not enclInReftype(e, _) and
|
||||
e.(Class).getCompilationUnit() = parent
|
||||
|
||||
@@ -471,7 +471,12 @@ class Method extends Callable, @method {
|
||||
}
|
||||
|
||||
override predicate isAbstract() {
|
||||
Callable.super.isAbstract()
|
||||
// The combination `abstract default` isn't legal in Java,
|
||||
// but it occurs when the Kotlin extractor records a default
|
||||
// body, but the output class file in fact uses an abstract
|
||||
// method and an associated static helper, which we don't
|
||||
// extract as an implementation detail.
|
||||
Callable.super.isAbstract() and not this.isDefault()
|
||||
or
|
||||
// JLS 9.4: An interface method lacking a `private`, `default`, or `static` modifier
|
||||
// is implicitly abstract.
|
||||
|
||||
Reference in New Issue
Block a user