Kotlin: Record that generated data class members are compiler-generated

This commit is contained in:
Ian Lynagh
2022-06-23 11:19:16 +01:00
parent 381bcf7dad
commit 5fc294d49e
3 changed files with 18 additions and 1 deletions

View File

@@ -783,6 +783,9 @@ open class KotlinFileExtractor(
val methodId = id.cast<DbMethod>()
tw.writeMethods(methodId, shortName.nameInDB, "${shortName.nameInDB}$paramsSignature", returnType.javaResult.id, parentId, sourceDeclaration.cast<DbMethod>())
tw.writeMethodsKotlinType(methodId, returnType.kotlinResult.id)
if (f.origin == IrDeclarationOrigin.GENERATED_DATA_CLASS_MEMBER) {
tw.writeCompiler_generated(methodId, 2)
}
if (extractMethodAndParameterTypeAccesses) {
extractTypeAccessRecursive(substReturnType, locId, id, -1)

View File

@@ -1211,10 +1211,15 @@ ktPropertyDelegates(
unique int variableId: @variable ref
)
/**
* If `id` is a compiler generated element, then the kind indicates the
* reason that the compiler generated it.
* See `Element.compilerGeneratedReason()` for an explanation of what
* each `kind` means.
*/
compiler_generated(
unique int id: @element ref,
int kind: int ref
// 1: Declaring classes of adapter functions in Kotlin
)
ktFunctionOriginalNames(

View File

@@ -44,6 +44,15 @@ class Element extends @element, Top {
/** Holds if this is an auxiliary program element generated by the compiler. */
predicate isCompilerGenerated() { compiler_generated(this, _) }
/** Gets the reason this element was generated by the compiler, if any. */
string compilerGeneratedReason() {
exists(int i | compiler_generated(this, i) |
i = 1 and result = "Declaring classes of adapter functions in Kotlin"
or
i = 2 and result = "Generated data class members"
)
}
}
/**