Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContributesBinding: Binding duplication error doesn't mention the source file #88

Open
kevinguitar opened this issue Feb 28, 2025 · 0 comments

Comments

@kevinguitar
Copy link

We're facing an error when the binding is duplicated somewhere in the graph. This is reproducible with the code below.

interface ParentInterface
      
@ContributesBinding(Any::class)
class ContributingInterface : ParentInterface
      
@ContributesBinding(Any::class)
class SecondContributingInterface : ParentInterface

The error

> Task :edu:app:kspDebugKotlin FAILED
e: [ksp] java.lang.IllegalStateException: Not possible
        at com.squareup.anvil.compiler.ContributedBindingKt.findHighestPriorityBinding(ContributedBinding.kt:152)
        at com.squareup.anvil.compiler.ContributedBindings$Companion.from(ContributedBinding.kt:94)
        at com.squareup.anvil.compiler.KspContributionMerger.generateDaggerAnnotation(KspContributionMerger.kt:675)
        at com.squareup.anvil.compiler.KspContributionMerger.processClass(KspContributionMerger.kt:326)
        at com.squareup.anvil.compiler.KspContributionMerger.processChecked(KspContributionMerger.kt:260)
        at com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor.runInternal(AnvilSymbolProcessing.kt:57)
        at com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor.process(AnvilSymbolProcessing.kt:47)
        at com.squareup.anvil.compiler.ClassScanningKspProcessor.processChecked(ClassScanningKspProcessor.kt:83)
        at com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor.runInternal(AnvilSymbolProcessing.kt:57)
        at com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor.process(AnvilSymbolProcessing.kt:47)

I see that there is a test case and it's passing just fine. Maybe it could be related to K2?

The libraries we're using

  • kotlin: 2.1.10
  • ksp: 2.1.10-1.0.30 (We're not using KSP2 yet)
  • anvil-ksp: 0.4.1
  • dagger: 2.55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant