@@ -85,13 +85,13 @@ trait FullParameterization {
8585 *
8686 * If a self type is present, $this has this self type as its type.
8787 */
88- def fullyParameterizedType (info : Type , clazz : ClassSymbol )(implicit ctx : Context ): Type = {
88+ def fullyParameterizedType (info : Type , clazz : ClassSymbol , abstractOverClass : Boolean = true )(implicit ctx : Context ): Type = {
8989 val (mtparamCount, origResult) = info match {
9090 case info @ PolyType (mtnames) => (mtnames.length, info.resultType)
9191 case info : ExprType => (0 , info.resultType)
9292 case _ => (0 , info)
9393 }
94- val ctparams = clazz.typeParams
94+ val ctparams = if (abstractOverClass) clazz.typeParams else Nil
9595 val ctnames = ctparams.map(_.name.unexpandedName())
9696
9797 /** The method result type */
@@ -104,7 +104,7 @@ trait FullParameterization {
104104 /** Replace class type parameters by the added type parameters of the polytype `pt` */
105105 def mapClassParams (tp : Type , pt : PolyType ): Type = {
106106 val classParamsRange = (mtparamCount until mtparamCount + ctparams.length).toList
107- tp.substDealias(clazz.typeParams , classParamsRange map (PolyParam (pt, _)))
107+ tp.substDealias(ctparams , classParamsRange map (PolyParam (pt, _)))
108108 }
109109
110110 /** The bounds for the added type paraneters of the polytype `pt` */
@@ -141,19 +141,21 @@ trait FullParameterization {
141141 /** The type parameters (skolems) of the method definition `originalDef`,
142142 * followed by the class parameters of its enclosing class.
143143 */
144- private def allInstanceTypeParams (originalDef : DefDef )(implicit ctx : Context ): List [Symbol ] =
145- originalDef.tparams.map(_.symbol) ::: originalDef.symbol.enclosingClass.typeParams
144+ private def allInstanceTypeParams (originalDef : DefDef , abstractOverClass : Boolean )(implicit ctx : Context ): List [Symbol ] =
145+ if (abstractOverClass)
146+ originalDef.tparams.map(_.symbol) ::: originalDef.symbol.enclosingClass.typeParams
147+ else originalDef.tparams.map(_.symbol)
146148
147149 /** Given an instance method definition `originalDef`, return a
148150 * fully parameterized method definition derived from `originalDef`, which
149151 * has `derived` as symbol and `fullyParameterizedType(originalDef.symbol.info)`
150152 * as info.
151153 */
152- def fullyParameterizedDef (derived : TermSymbol , originalDef : DefDef )(implicit ctx : Context ): Tree =
154+ def fullyParameterizedDef (derived : TermSymbol , originalDef : DefDef , abstractOverClass : Boolean = true )(implicit ctx : Context ): Tree =
153155 polyDefDef(derived, trefs => vrefss => {
154156 val origMeth = originalDef.symbol
155157 val origClass = origMeth.enclosingClass.asClass
156- val origTParams = allInstanceTypeParams(originalDef)
158+ val origTParams = allInstanceTypeParams(originalDef, abstractOverClass )
157159 val origVParams = originalDef.vparamss.flatten map (_.symbol)
158160 val thisRef :: argRefs = vrefss.flatten
159161
@@ -218,9 +220,9 @@ trait FullParameterization {
218220 * - the `this` of the enclosing class,
219221 * - the value parameters of the original method `originalDef`.
220222 */
221- def forwarder (derived : TermSymbol , originalDef : DefDef )(implicit ctx : Context ): Tree =
223+ def forwarder (derived : TermSymbol , originalDef : DefDef , abstractOverClass : Boolean = true )(implicit ctx : Context ): Tree =
222224 ref(derived.termRef)
223- .appliedToTypes(allInstanceTypeParams(originalDef).map(_.typeRef))
225+ .appliedToTypes(allInstanceTypeParams(originalDef, abstractOverClass ).map(_.typeRef))
224226 .appliedTo(This (originalDef.symbol.enclosingClass.asClass))
225227 .appliedToArgss(originalDef.vparamss.nestedMap(vparam => ref(vparam.symbol)))
226228 .withPos(originalDef.rhs.pos)
0 commit comments