Skip to content

Fix/#569 new ref array #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,26 @@ object Erasure extends TypeTestsCasts{
tpt = untpd.TypedSplice(TypeTree(sym.info).withPos(vdef.tpt.pos))), sym)

override def typedDefDef(ddef: untpd.DefDef, sym: Symbol)(implicit ctx: Context) = {
val restpe = sym.info.resultType
var effectiveSym = sym
if (sym == defn.newRefArrayMethod) {
// newRefArray is treated specially: It's the only source-defined method
// that has a polymorphic type after erasure. But treating its (dummy) definition
// with a polymorphic type at and after erasure is an awkward special case.
// We therefore rewrite the method definition with a new Symbol of type
// (length: Int)Object
val MethodType(pnames, ptypes) = sym.info.resultType
effectiveSym = sym.copy(info = MethodType(pnames, ptypes, defn.ObjectType))
}
val restpe = effectiveSym.info.resultType
val ddef1 = untpd.cpy.DefDef(ddef)(
tparams = Nil,
vparamss = (outer.paramDefs(sym) ::: ddef.vparamss.flatten) :: Nil,
vparamss = (outer.paramDefs(effectiveSym) ::: ddef.vparamss.flatten) :: Nil,
tpt = untpd.TypedSplice(TypeTree(restpe).withPos(ddef.tpt.pos)),
rhs = ddef.rhs match {
case id @ Ident(nme.WILDCARD) => untpd.TypedSplice(id.withType(restpe))
case _ => ddef.rhs
})
super.typedDefDef(ddef1, sym)
super.typedDefDef(ddef1, effectiveSym)
}

/** After erasure, we may have to replace the closure method by a bridge.
Expand Down Expand Up @@ -600,7 +610,7 @@ object Erasure extends TypeTestsCasts{

traverse(newStats, oldStats)
}

private final val NoBridgeFlags = Flags.Accessor | Flags.Deferred | Flags.Lazy

/** Create a bridge DefDef which overrides a parent method.
Expand Down