Skip to content

Commit 7fe148d

Browse files
committed
Merge pull request #152 from dotty-staging/fux/substThis
Fix of FullParameterization
2 parents e1aecf1 + a9aa810 commit 7fe148d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/dotty/tools/dotc/core/Types.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,10 @@ object Types {
832832
final def substThis(cls: ClassSymbol, tp: Type)(implicit ctx: Context): Type =
833833
ctx.substThis(this, cls, tp, null)
834834

835+
/** As substThis, but only is class is a static owner (i.e. a globally accessible object) */
836+
final def substThisUnlessStatic(cls: ClassSymbol, tp: Type)(implicit ctx: Context): Type =
837+
if (cls.isStaticOwner) this else ctx.substThis(this, cls, tp, null)
838+
835839
/** Substitute all occurrences of `RefinedThis(rt)` by `tp` */
836840
final def substThis(rt: RefinedType, tp: Type)(implicit ctx: Context): Type =
837841
ctx.substThis(this, rt, tp, null)

src/dotty/tools/dotc/transform/FullParameterization.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ trait FullParameterization {
9898
def resultType(mapClassParams: Type => Type) = {
9999
val thisParamType = mapClassParams(clazz.classInfo.selfType)
100100
MethodType(nme.SELF :: Nil, thisParamType :: Nil)(mt =>
101-
mapClassParams(origResult).substThis(clazz, MethodParam(mt, 0)))
101+
mapClassParams(origResult).substThisUnlessStatic(clazz, MethodParam(mt, 0)))
102102
}
103103

104104
/** Replace class type parameters by the added type parameters of the polytype `pt` */
@@ -203,7 +203,7 @@ trait FullParameterization {
203203
typeMap = rewireType(_)
204204
.subst(origTParams, trefs)
205205
.subst(origVParams, argRefs.map(_.tpe))
206-
.substThis(origClass, thisRef.tpe),
206+
.substThisUnlessStatic(origClass, thisRef.tpe),
207207
ownerMap = (sym => if (sym eq origMeth) derived else sym),
208208
treeMap = {
209209
case tree: This if tree.symbol == origClass => thisRef

0 commit comments

Comments
 (0)