Skip to content

Allow type parameters binding, with star type added #694

Open
@matejdro

Description

When attempting to multibind classes with type parameters:

@ContributesMultibinding(SomeScope::class)
class MyClass: SomeInterface<String>

Anvil will complain that Type parameters in bindings are not supported. This binding needs to be contributed in a Dagger module manually.

I understand that this is a problem, because Anvil can't know what type parameter should be used on bound type (there is no way to specify that in annotation). But, maybe we could just support the most basic version?

We could just add star to all type bindings, so above example would get bound to the SomeInterface<*> type. It does not cover many use cases, but I think it's still better than not supporting this at all. Any other non-star cases can still use module like now.

I'm willing to submit PR for this, if desired.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions