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.