@@ -33,7 +33,7 @@ object HoistSuperArgs {
3333 *
3434 * An argument is complex if it contains a method or template definition, a this or a new,
3535 * or it contains an identifier which needs a `this` prefix to be accessed. This is the case
36- * if the identifer neither a global reference nor a reference to a parameter of the enclosing class.
36+ * if the identifier has neither a global reference nor a reference to a parameter of the enclosing class.
3737 * @see needsHoist for an implementation.
3838 *
3939 * A hoisted argument definition gets the parameters of the class it is hoisted from
@@ -116,21 +116,26 @@ class HoistSuperArgs extends MiniPhase with IdentityDenotTransformer { thisPhase
116116 case _ => false
117117 }
118118
119+ /** Only rewire types that are owned by the current Hoister and is an param or accessor */
120+ def needsRewire (tp : Type ) = tp match {
121+ case ntp : NamedType =>
122+ (ntp.symbol.owner == cls || ntp.symbol.owner == constr) && ntp.symbol.isParamOrAccessor
123+ case _ => false
124+ }
125+
119126 // begin hoistSuperArg
120127 arg match {
121128 case Apply (fn, arg1 :: Nil ) if fn.symbol == defn.cbnArg =>
122129 cpy.Apply (arg)(fn, hoistSuperArg(arg1, cdef) :: Nil )
123- case _ if ( arg.existsSubTree(needsHoist) ) =>
130+ case _ if arg.existsSubTree(needsHoist) =>
124131 val superMeth = newSuperArgMethod(arg.tpe)
125132 val superArgDef = polyDefDef(superMeth, trefs => vrefss => {
126133 val paramSyms = trefs.map(_.typeSymbol) ::: vrefss.flatten.map(_.symbol)
127134 val tmap = new TreeTypeMap (
128135 typeMap = new TypeMap {
129136 lazy val origToParam = origParams.zip(paramSyms).toMap
130137 def apply (tp : Type ) = tp match {
131- case tp : NamedType
132- if (tp.symbol.owner == cls || tp.symbol.owner == constr) &&
133- tp.symbol.isParamOrAccessor =>
138+ case tp : NamedType if needsRewire(tp) =>
134139 origToParam.get(tp.symbol) match {
135140 case Some (mappedSym) => if (tp.symbol.isType) mappedSym.typeRef else mappedSym.termRef
136141 case None => mapOver(tp)
@@ -140,7 +145,7 @@ class HoistSuperArgs extends MiniPhase with IdentityDenotTransformer { thisPhase
140145 }
141146 },
142147 treeMap = {
143- case tree : RefTree if paramSyms.contains (tree.symbol ) =>
148+ case tree : RefTree if needsRewire (tree.tpe ) =>
144149 cpy.Ident (tree)(tree.name).withType(tree.tpe)
145150 case tree =>
146151 tree
0 commit comments