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:
Chris Smowton
2022-10-19 16:48:28 +01:00
committed by GitHub
12 changed files with 193 additions and 155 deletions

View File

@@ -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()
}
/**