@@ -469,16 +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 = sym.info.resultType
472
+ var effectiveSym = sym
473
+ if (sym == defn.newRefArrayMethod) {
474
+ // newRefArray is treated specially: It's the only 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
473
483
val ddef1 = untpd.cpy.DefDef (ddef)(
474
484
tparams = Nil ,
475
- vparamss = (outer.paramDefs(sym ) ::: ddef.vparamss.flatten) :: Nil ,
485
+ vparamss = (outer.paramDefs(effectiveSym ) ::: ddef.vparamss.flatten) :: Nil ,
476
486
tpt = untpd.TypedSplice (TypeTree (restpe).withPos(ddef.tpt.pos)),
477
487
rhs = ddef.rhs match {
478
488
case id @ Ident (nme.WILDCARD ) => untpd.TypedSplice (id.withType(restpe))
479
489
case _ => ddef.rhs
480
490
})
481
- super .typedDefDef(ddef1, sym )
491
+ super .typedDefDef(ddef1, effectiveSym )
482
492
}
483
493
484
494
/** After erasure, we may have to replace the closure method by a bridge.
@@ -600,7 +610,7 @@ object Erasure extends TypeTestsCasts{
600
610
601
611
traverse(newStats, oldStats)
602
612
}
603
-
613
+
604
614
private final val NoBridgeFlags = Flags .Accessor | Flags .Deferred | Flags .Lazy
605
615
606
616
/** Create a bridge DefDef which overrides a parent method.
0 commit comments