Kapt: dump declaration origins produced by backend
This will be useful in diagnosing behavior differences between JVM and JVM_IR versions of kapt.
This commit is contained in:
+3
@@ -23,6 +23,9 @@ class JvmDeclarationOrigin(
|
||||
val descriptor: DeclarationDescriptor?,
|
||||
val parametersForJvmOverload: List<KtParameter?>? = null
|
||||
) {
|
||||
override fun toString(): String =
|
||||
if (this == NO_ORIGIN) "NO_ORIGIN" else "origin=$originKind element=${element?.javaClass?.simpleName} descriptor=$descriptor"
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val NO_ORIGIN: JvmDeclarationOrigin = JvmDeclarationOrigin(OTHER, null, null)
|
||||
|
||||
+17
@@ -142,6 +142,10 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
private var done = false
|
||||
|
||||
fun convert(): List<KaptStub> {
|
||||
if (kaptContext.logger.isVerbose) {
|
||||
dumpDeclarationOrigins()
|
||||
}
|
||||
|
||||
if (done) error(ClassFileToSourceStubConverter::class.java.simpleName + " can convert classes only once")
|
||||
done = true
|
||||
|
||||
@@ -154,6 +158,19 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
return stubs
|
||||
}
|
||||
|
||||
private fun dumpDeclarationOrigins() {
|
||||
kaptContext.logger.info("Declaration origins:")
|
||||
for ((key, value) in kaptContext.origins) {
|
||||
val element = when (key) {
|
||||
is ClassNode -> "class ${key.name}"
|
||||
is FieldNode -> "field ${key.name}:${key.desc}"
|
||||
is MethodNode -> "method ${key.name}${key.desc}"
|
||||
else -> key.javaClass.toString()
|
||||
}
|
||||
kaptContext.logger.info("$element -> $value")
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateNonExistentClass(): JCCompilationUnit {
|
||||
val nonExistentClass = treeMaker.ClassDef(
|
||||
treeMaker.Modifiers((Flags.PUBLIC or Flags.FINAL).toLong()),
|
||||
|
||||
Reference in New Issue
Block a user