uber / motif

A simple DI API for Android / Java
Apache License 2.0
533 stars 43 forks source link

Could not resolve type for nested Java classes #249

Closed jbarr21 closed 1 year ago

jbarr21 commented 2 years ago

On Kotlin 1.6.21 and KSP 1.6.21-1.0.6 (branch), Motif generates the ScopeImpl class for JavaScope.java just fine: ./gradlew :samples:sample-lib-ksp:clean :samples:sample-lib-ksp:assembleDebug generates the file: samples/sample-lib-ksp/build/generated/ksp/debug/kotlin/com/example/sample_lib_ksp/JavaScopeImpl.kt.

However, after the upgrade to Kotlin 1.7.10 and KSP 1.7.10-1.0.6 (commit), the same command fails during KSP processing due to the type for the nested class JavaScope$Objects not being able to be resolved:

> Task :samples:sample-lib-ksp:kspDebugKotlin FAILED
e: [ksp] java.lang.IllegalStateException: Could not resolve type for nested class: com.example.sample_lib_ksp.JavaScope.Objects
    at motif.ast.compiler.CompilerClass$nestedClasses$2.invoke(CompilerClass.kt:92)
    at motif.ast.compiler.CompilerClass$nestedClasses$2.invoke(CompilerClass.kt:89)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at motif.ast.compiler.CompilerClass.getNestedClasses(CompilerClass.kt:89)
    at motif.ast.IrClass.annotatedInnerClass(IrClass.kt:42)
    at motif.models.Objects$Companion.fromScope(Objects.kt:32)
    at motif.models.ValidScope.<init>(Scope.kt:58)
    at motif.models.ScopeFactory.visit(Scope.kt:108)
    at motif.models.ScopeFactory.create(Scope.kt:94)
    at motif.models.Scope$Companion.fromClasses(Scope.kt:37)
    at motif.core.ResolvedGraph$Companion.create(ResolvedGraph.kt:64)
    at motif.compiler.MotifProcessingStep.process(MotifProcessingStep.kt:63)
    at androidx.room.compiler.processing.CommonProcessorDelegate.processLastRound(XBasicAnnotationProcessor.kt:150)
    at androidx.room.compiler.processing.ksp.KspBasicAnnotationProcessor.finish(KspBasicAnnotationProcessor.kt:76)
    at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:266)
    at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:265)
    at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:330)
    at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:265)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:123)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:99)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:264)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:55)
    at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:255)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:101)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:60)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:157)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:94)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1642)