@@ -1226,18 +1226,18 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
12261226 val body : mutable.Map [Symbol , Tree ] = new mutable.HashMap
12271227
12281228 /** Map a specializable method to its value parameter symbols. */
1229- val parameters : mutable.Map [Symbol , List [List [ Symbol ]]] = new mutable. HashMap
1229+ val parameters = mutable.HashMap [Symbol , List [Symbol ]]()
12301230
12311231 /** Collect method bodies that are concrete specialized methods.
12321232 */
12331233 class CollectMethodBodies extends Traverser {
12341234 override def traverse (tree : Tree ) = tree match {
1235- case DefDef (mods, name, tparams, vparamss , tpt, rhs) =>
1235+ case DefDef (mods, name, tparams, vparams :: Nil , tpt, rhs) =>
12361236 if (concreteSpecMethods(tree.symbol) || tree.symbol.isConstructor) {
12371237 debuglog(" !!! adding body of a defdef %s, symbol %s: %s" .format(tree, tree.symbol, rhs))
12381238 body(tree.symbol) = rhs
12391239 // body(tree.symbol) = tree // whole method
1240- parameters(tree.symbol) = mmap(vparamss) (_.symbol)
1240+ parameters(tree.symbol) = vparams.map (_.symbol)
12411241 concreteSpecMethods -= tree.symbol
12421242 } // no need to descend further down inside method bodies
12431243
@@ -1531,12 +1531,6 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
15311531 }
15321532 }
15331533
1534- private def reskolemize (tparams : List [TypeDef ]): (List [Symbol ], List [Symbol ]) = {
1535- val saved = tparams map (_.symbol)
1536- localTyper skolemizeTypeParams tparams
1537- (saved, tparams map (_.symbol))
1538- }
1539-
15401534 private def duplicateBody (tree : DefDef , source : Symbol ) = {
15411535 val symbol = tree.symbol
15421536 val meth = addBody(tree, source)
@@ -1560,36 +1554,37 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
15601554 */
15611555 private def addBody (tree : DefDef , source : Symbol ): DefDef = {
15621556 val symbol = tree.symbol
1563- debuglog(" specializing body of" + symbol.fullName + " : " + symbol.info )
1564- val DefDef (mods, name, tparams, vparamss , tpt, _) = tree
1557+ debuglog(" specializing body of" + symbol.defString )
1558+ val DefDef (mods, name, tparams, vparams :: Nil , tpt, _) = tree
15651559// val (_, origtparams) = splitParams(source.typeParams)
15661560 val env = typeEnv(symbol)
15671561 val boundTvars = env.keySet
15681562 val origtparams = source.typeParams.filter(tparam => ! boundTvars(tparam) || ! isScalaValueType(env(tparam)))
15691563 debuglog(" substituting " + origtparams + " for " + symbol.typeParams)
15701564
15711565 // skolemize type parameters
1572- val (oldtparams, newtparams) = reskolemize(tparams)
1566+ val oldtparams = tparams map (_.symbol)
1567+ val newtparams = deriveFreshSkolems(oldtparams)
1568+ map2(tparams, newtparams)(_ setSymbol _)
15731569
15741570 // create fresh symbols for value parameters to hold the skolem types
1575- val vparamss1 = List (for (vdef <- vparamss.head; param = vdef.symbol) yield {
1576- ValDef (param cloneSymbol symbol substInfo (oldtparams, newtparams))
1577- })
1571+ val newSyms = cloneSymbolsAtOwnerAndModify(vparams map (_.symbol), symbol, _.substSym(oldtparams, newtparams))
15781572
15791573 // replace value and type parameters of the old method with the new ones
15801574 // log("Adding body for " + tree.symbol + " - origtparams: " + origtparams + "; tparams: " + tparams)
15811575 // log("Type vars of: " + source + ": " + source.typeParams)
15821576 // log("Type env of: " + tree.symbol + ": " + boundTvars)
15831577 // log("newtparams: " + newtparams)
15841578 val symSubstituter = new ImplementationAdapter (
1585- parameters(source).flatten ::: origtparams,
1586- vparamss1.flatten.map(_.symbol) ::: newtparams,
1579+ parameters(source) ::: origtparams,
1580+ newSyms ::: newtparams,
15871581 source.enclClass,
15881582 false ) // don't make private fields public
1589- val tmp = symSubstituter(body(source).duplicate)
1583+
1584+ val newBody = symSubstituter(body(source).duplicate)
15901585 tpt.tpe = tpt.tpe.substSym(oldtparams, newtparams)
15911586
1592- treeCopy.DefDef (tree, mods, name, tparams, vparamss1 , tpt, tmp )
1587+ treeCopy.DefDef (tree, mods, name, tparams, List (newSyms map ValDef ) , tpt, newBody )
15931588 }
15941589
15951590 /** Create trees for specialized members of 'sClass', based on the
@@ -1610,9 +1605,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
16101605 if (m.isMethod) {
16111606 if (info(m).target.hasAccessorFlag) hasSpecializedFields = true
16121607 if (m.isClassConstructor) {
1613- val origParamss = parameters(info(m).target)
1608+ val origParams = parameters(info(m).target)
16141609 val vparams = (
1615- map2(m.info.paramTypes, origParamss( 0 ) )((tp, sym) =>
1610+ map2(m.info.paramTypes, origParams )((tp, sym) =>
16161611 m.newValue(specializedName(sym, typeEnv(sClass)), sym.pos, sym.flags) setInfo tp
16171612 )
16181613 )
0 commit comments