-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Labels
FIRbugSomething isn't workingSomething isn't workingcompilerAnything specific to the metro compiler itselfAnything specific to the metro compiler itselfwaiting for upstreamThis issue or PR is dependent on upstream Kotlin compiler changes/fixesThis issue or PR is dependent on upstream Kotlin compiler changes/fixes
Description
Description
When a binding container defines a type A and also contains an @Provides method with return type A, the return type cannot be resolved and results in an error like:
Somewhere in file /private/var/folders/wv/bkgjhyrj3l5f8pwkh_kfds000000gn/T/dev.zacsweers.metro.compiler.BoxTestGenerated$Bindingcontainers7641testProviderForTypeDefinedInContainer/kotlin-sources/main/ProviderForTypeDefinedInContainer.kt: java.lang.IllegalStateException: Could not resolve provider return type for provider: /MyContainer.provideMyType
This can happen if the provider references a class that is nested within the same parent class and has cyclical references to other classes.
@R|dev/zacsweers/metro/Provides|() public? final? fun provideMyType(): MyType {
^provideMyType object : MyType {
private constructor(): R|<anonymous>| {
super<<implicit>>()
}
}
}
. This is a bug in the Metro compiler, please report it to https://github.com/zacsweers/metro.
at org.jetbrains.kotlin.util.AnalysisExceptionsKt.wrapIntoFileAnalysisExceptionIfNeeded(AnalysisExceptions.kt:62)
at org.jetbrains.kotlin.fir.FirCliExceptionHandler.handleExceptionOnFileAnalysis(Utils.kt:267)
at org.jetbrains.kotlin.fir.resolve.transformers.FirSupertypeResolverTransformer.transformFile(FirSupertypesResolution.kt:861)
Self-contained Reproducer
This is a minimal reproducer:
@BidningContainer
@ContributesTo(AppScope::class)
object MyContainer {
@Provides fun provideMyType(): MyType {
return object : MyType
}
interface MyType
}
@SingleIn(AppScope::class)
@DependencyGraph(AppScope::class)
interface AppGraph {
val myType: MyContainer.MyType
}
Metro version
0.7.4
Context
No response
Metadata
Metadata
Assignees
Labels
FIRbugSomething isn't workingSomething isn't workingcompilerAnything specific to the metro compiler itselfAnything specific to the metro compiler itselfwaiting for upstreamThis issue or PR is dependent on upstream Kotlin compiler changes/fixesThis issue or PR is dependent on upstream Kotlin compiler changes/fixes