Skip to content

Commit 65e38f2

Browse files
committed
Fix for scala#4342
1 parent ae816fb commit 65e38f2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,23 @@ object ExplicitOuter {
336336
class OuterOps(val ictx: Context) extends AnyVal {
337337
private implicit def ctx: Context = ictx
338338

339+
private def outerType(cls: ClassSymbol): Type = {
340+
val encl = cls.owner.enclosingClass
341+
if (cls.is(Scala2x))
342+
encl.asClass.classInfo.selfInfo match {
343+
case tp: TypeRef => tp.classSymbol.typeRef
344+
case self: Symbol => self.typeRef
345+
case _ => encl.typeRef
346+
}
347+
else encl.typeRef
348+
}
349+
339350
/** If `cls` has an outer parameter add one to the method type `tp`. */
340351
def addParam(cls: ClassSymbol, tp: Type): Type =
341352
if (hasOuterParam(cls)) {
342353
val mt @ MethodTpe(pnames, ptypes, restpe) = tp
343354
mt.derivedLambdaType(
344-
nme.OUTER :: pnames, cls.owner.enclosingClass.typeRef :: ptypes, restpe)
355+
nme.OUTER :: pnames, outerType(cls) :: ptypes, restpe)
345356
} else tp
346357

347358
/** If function in an apply node is a constructor that needs to be passed an

0 commit comments

Comments
 (0)