Skip to content

ScalaMultibinder doesn't allow multiple modules to contribute, as Guice Multibinder does #29

@kahliburke

Description

@kahliburke

If I create a Guice Multibinder for some type, I am allowed to do this from multiple modules, specifically the

Multibinder.newSetBinder(binder, type)

method can be called in as many modules as I'd like, which allows me to have multiple modules dynamically contribute to the set of types, instances, etc. configured.

However, if I do the following:

val multi1 = ScalaMultibinder.newSetBinder[Int](binder)
multi1.addBinding().toInstance(1)
val multi2 = ScalaMultibinder.newSetBinder[Int](binder)
multi2.addBinding().toInstance(2)

I get an exception from Guice that the binding configuration has already occurred:

A binding to scala.collection.immutable.Set<java.lang.Integer> was already configured at     
net.codingwell.scalaguice.ScalaMultibinder$.newSetBinder(MultiBinder.scala:106).

This makes the ScalaMultibinder much less useful. Not sure if this is a bug or by design but it prevents me from being able to use the ScalaMultibinder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions