Closed cacoco closed 4 years ago
I should note that this works as expected in scalaguice 4.2.0 which is pre-transition from Manifests to TypeTags and currently blocks our upgrade of Finatra to the latest version (which supports Scala 2.13 and part of why we're looking to upgrade).
Always something. Does look like the type conversions needs a special case for primitive arrays.
This (new) test fails
it("should handle Primative Arrays") {
typeLiteral[Option[Array[Byte]]] shouldEqual new TypeLiteral[Option[Array[Byte]]] {}
}
I'll look at it in my spare time, if you have any thoughts about how to do that let me know
I believe i fixed it. I'll see about commiting and publishing in a bit.
Should be fixed in 4.2.8 which should be synced with Maven Central in the next hour or two.
@tsuckow thanks a ton -- we appreciate it.
We have a case where a Module provides a type of
Foo[Array[Byte]]
to the object graph via an@Provides
-annotated method in a Module. When that type is manually looked up viainjector.instance[Foo[Array[Byte]]]
it is not found.It appears as though the
TypeLiteral
built bynet.codingwell.scalaguice.typeLiteral
ends up using thejava.lang.Byte[]
boxed type as the generic arg type, so the Key is built for typeFoo[java.lang.Byte[]]
, though the type bound is actually the primitive,byte[]
type --Foo[byte[]]
.This is on Scala 2.12.10 running JDK 8 and using scalaguice 4.2.7 and google guice 4.2.3.
Example:
Tracing it through, it seems that the
TypeConversions.scalaTypeToJavaType
does not properly handle this case for building a JavaType or at least builds one that will not match the type bound to the object graph. Any help or guidance would be appreciated. Thanks!