Skip to content

Commit 44d9da1

Browse files
committed
Streamline outerPrefix
1 parent ab4b12c commit 44d9da1

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -343,25 +343,12 @@ object ExplicitOuter {
343343
private final val HoistableFlags = Method | Lazy | Module
344344

345345
/** The outer prefix implied by type `tpe` */
346-
private def outerPrefix(tpe: Type)(using Context): Type = tpe match {
347-
case tpe: TypeRef =>
348-
tpe.symbol match {
349-
case cls: ClassSymbol =>
350-
if (tpe.prefix eq NoPrefix) cls.owner.enclosingClass.thisType
351-
else tpe.prefix
352-
case _ =>
353-
// Need to be careful to dealias before erasure, otherwise we lose prefixes.
354-
atPhaseNoLater(erasurePhase)(outerPrefix(tpe.underlying))
355-
// underlying is fine here and below since we are calling this after erasure.
356-
// However, there is some weird stuff going on with parboiled2 where an
357-
// AppliedType with a type alias as constructor is fed to outerPrefix.
358-
// For some other unknown reason this works with underlying but not with superType.
359-
// I was not able to minimize the problem and parboiled2 spits out way too much
360-
// macro generated code to be able to pinpoint the root problem.
361-
}
346+
private def outerPrefix(tpe: Type)(using Context): Type = tpe match
347+
case tpe: TypeRef if tpe.symbol.isClass =>
348+
if tpe.prefix eq NoPrefix then tpe.symbol.owner.enclosingClass.thisType
349+
else tpe.prefix
362350
case tpe: TypeProxy =>
363351
atPhaseNoLater(erasurePhase)(outerPrefix(tpe.superType))
364-
}
365352

366353
/** It's possible (i1755.scala gives an example) that the type
367354
* given by outerPrefix contains a This-reference to a module outside

0 commit comments

Comments
 (0)