@@ -469,20 +469,26 @@ object Erasure extends TypeTestsCasts{
469
469
tpt = untpd.TypedSplice (TypeTree (sym.info).withPos(vdef.tpt.pos))), sym)
470
470
471
471
override def typedDefDef (ddef : untpd.DefDef , sym : Symbol )(implicit ctx : Context ) = {
472
- val restpe =
473
- if (sym == defn.newRefArrayMethod) defn.ObjectType
474
- // newRefArray is the only source defined method that's polymorphic
475
- // after erasure; needs to be treated specially
476
- else sym.info.resultType
472
+ var effectiveSym = sym
473
+ if (sym == defn.newRefArrayMethod) {
474
+ // newRefArray is treated specially: It's new only method source-defined method
475
+ // that has a polymorphic type after erasure. But treating its (dummy) definition
476
+ // with a polymorphic type at and after erasure is an awkward special case.
477
+ // We therefore rewrite the method definition with a new Symbol of type
478
+ // (length: Int)Object
479
+ val MethodType (pnames, ptypes) = sym.info.resultType
480
+ effectiveSym = sym.copy(info = MethodType (pnames, ptypes, defn.ObjectType ))
481
+ }
482
+ val restpe = effectiveSym.info.resultType
477
483
val ddef1 = untpd.cpy.DefDef (ddef)(
478
484
tparams = Nil ,
479
- vparamss = (outer.paramDefs(sym ) ::: ddef.vparamss.flatten) :: Nil ,
485
+ vparamss = (outer.paramDefs(effectiveSym ) ::: ddef.vparamss.flatten) :: Nil ,
480
486
tpt = untpd.TypedSplice (TypeTree (restpe).withPos(ddef.tpt.pos)),
481
487
rhs = ddef.rhs match {
482
488
case id @ Ident (nme.WILDCARD ) => untpd.TypedSplice (id.withType(restpe))
483
489
case _ => ddef.rhs
484
490
})
485
- super .typedDefDef(ddef1, sym )
491
+ super .typedDefDef(ddef1, effectiveSym )
486
492
}
487
493
488
494
/** After erasure, we may have to replace the closure method by a bridge.
0 commit comments