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

boundType does not support Any #680

Closed
gmarques33 opened this issue Jan 20, 2023 · 0 comments · Fixed by #681
Closed

boundType does not support Any #680

gmarques33 opened this issue Jan 20, 2023 · 0 comments · Fixed by #681

Comments

@gmarques33
Copy link
Contributor

Same as #619

This piece of code:

@ContributesMultibinding(ActivityInjection::class, boundType = Any::class)
class TestViewModel @Inject constructor() : SimpleStackViewModel() {
...
}

Will throw the follow error:

com.squareup.anvil.compiler.api.AnvilCompilationException: Back-end (JVM) Internal error: com.squareup.anvil.annotations.ContributesMultibinding contributes a binding for kotlin.Any, but doesn't extend this type.

The ContributesBindingGenerator works correctly and the test introduced in https://github.com/square/anvil/pull/623/files passes, if there's a component the BindingModuleGenerator will fail when merging the classes.

The following test fails:

  @Test fun `the contributed multibinding class can extend Any explicitly`() {
    compile(
      """
      package com.squareup.test

      import com.squareup.anvil.annotations.MergeComponent
      import com.squareup.anvil.annotations.ContributesMultibinding

      @ContributesMultibinding(Int::class, boundType = Any::class)
      interface ContributingInterface

      @MergeComponent(
        scope = Int::class,
      )
      interface ApplicationComponent
      """,
      ) {
      assertThat(this.exitCode).isEqualTo(ExitCode.OK)
    }
  }
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

Successfully merging a pull request may close this issue.

1 participant