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

ScalaMapBinder does not support traits as type #50

Open
Vadi opened this issue Sep 8, 2015 · 2 comments
Open

ScalaMapBinder does not support traits as type #50

Vadi opened this issue Sep 8, 2015 · 2 comments

Comments

@Vadi
Copy link

Vadi commented Sep 8, 2015

Suppose you've a trait that you will implement in child classes -

trait AppMessage {}

Given this injections

    val mapBinder = ScalaMapBinder.newMapBinder[String, AppMessage](binder)
    mapBinder.addBinding("A").toInstance(new AppMessageSampleA)
    mapBinder.addBinding("B").toInstance(new AppMessageSampleB)

and calling them with val map = injector.instance[im.Map[String, AppMessage]] throws not found exception.

Need to support traits

@nbauernfeind
Copy link
Member

I don't immediately see why this shouldn't already work. In this case the trait is effectively an interface. Thanks for reporting.

I don't have time to look today, but I will tomorrow.

@Daniel-Khodabakhsh
Copy link

Daniel-Khodabakhsh commented Mar 7, 2022

I tested this out on version 5.0.2 and it works well with Scala traits now.

The trait I used is one I wrote myself and does not extend any other trait. The inject class also only extends this one trait. Haven't tested with more complex traits.

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

3 participants