"progression test: can't handle AnyVals" in {
import TraitCase6._
val definition = new ModuleDef {
make[Dep]
make[AnyValDep].from(AnyValDep(_))
make[TestTrait]
}
val injector = mkInjector()
val plan = injector.plan(definition)
val context = injector.produce(plan)
assert(context.get[TestTrait].anyValDep != null)
// AnyVal reboxing happened
assert(context.get[TestTrait].anyValDep ne context.get[AnyValDep].asInstanceOf[AnyRef])
assert(context.get[TestTrait].anyValDep.d eq context.get[Dep])
}
On the != null assertion with:
class com.github.pshirshov.izumi.distage.fixtures.TraitCases$TraitCase6$AnyValDep cannot be cast to class com.github.pshirshov.izumi.distage.fixtures.TraitCases$TraitCase6$Dep (com.github.pshirshov.izumi.distage.fixtures.TraitCases$TraitCase6$AnyValDep and com.github.pshirshov.izumi.distage.fixtures.TraitCases$TraitCase6$Dep are in unnamed module of loader 'app')
java.lang.ClassCastException: class com.github.pshirshov.izumi.distage.fixtures.TraitCases$TraitCase6$AnyValDep cannot be cast to class com.github.pshirshov.izumi.distage.fixtures.TraitCases$TraitCase6$Dep (com.github.pshirshov.izumi.distage.fixtures.TraitCases$TraitCase6$AnyValDep and com.github.pshirshov.izumi.distage.fixtures.TraitCases$TraitCase6$Dep are in unnamed module of loader 'app')
at com.github.pshirshov.izumi.distage.fixtures.TraitCases$TraitCase6$TestTrait$$EnhancerByCGLIB$$ceccd269.anyValDep(<generated>)
at com.github.pshirshov.izumi.distage.injector.AutoTraitsTest.$anonfun$new$11(AutoTraitsTest.scala:145)
The same test for distage-static macro auto-traits passes.
Fix: use the same AnyVal unboxing logic in CgLibTraitMethodInterceptor.intercept from ClassStrategyDefaultImpl
This test fails:
On the
!= null
assertion with:The same test for distage-static macro auto-traits passes.
Fix: use the same AnyVal unboxing logic in
CgLibTraitMethodInterceptor.intercept
fromClassStrategyDefaultImpl