mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
Merge pull request #10853 from smowton/smowton/fix/specialised-anon-classes
Kotlin: extract called private methods of specialised types, and specialised instances of anonymous types
This commit is contained in:
@@ -686,7 +686,7 @@ class SrcRefType extends RefType {
|
||||
/** A class declaration. */
|
||||
class Class extends ClassOrInterface, @class {
|
||||
/** Holds if this class is an anonymous class. */
|
||||
predicate isAnonymous() { isAnonymClass(this, _) }
|
||||
predicate isAnonymous() { isAnonymClass(this.getSourceDeclaration(), _) }
|
||||
|
||||
override RefType getSourceDeclaration() { classes(this, _, _, result) }
|
||||
|
||||
@@ -800,10 +800,13 @@ class AnonymousClass extends NestedClass {
|
||||
}
|
||||
|
||||
/** Gets the class instance expression where this anonymous class occurs. */
|
||||
ClassInstanceExpr getClassInstanceExpr() { isAnonymClass(this, result) }
|
||||
ClassInstanceExpr getClassInstanceExpr() { isAnonymClass(this.getSourceDeclaration(), result) }
|
||||
|
||||
override string toString() {
|
||||
result = "new " + this.getClassInstanceExpr().getTypeName() + "(...) { ... }"
|
||||
// Include super.toString, i.e. the name given in the database, because for Kotlin anonymous
|
||||
// classes we can get specialisations of anonymous generic types, and this will supply the
|
||||
// trailing type arguments.
|
||||
result = "new " + this.getClassInstanceExpr().getTypeName() + "(...) { ... }" + super.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user