File tree 2 files changed +17
-18
lines changed
compiler/src/dotty/tools/dotc/transform
2 files changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -343,25 +343,12 @@ object ExplicitOuter {
343
343
private final val HoistableFlags = Method | Lazy | Module
344
344
345
345
/** 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
362
350
case tpe : TypeProxy =>
363
- outerPrefix(tpe.underlying)
364
- }
351
+ atPhaseNoLater(erasurePhase)(outerPrefix(tpe.superType))
365
352
366
353
/** It's possible (i1755.scala gives an example) that the type
367
354
* given by outerPrefix contains a This-reference to a module outside
Original file line number Diff line number Diff line change
1
+ object Outer :
2
+ def Test =
3
+ object Inner :
4
+ var x : Int = 2
5
+ class Rgb ():
6
+ def f = x
7
+
8
+ type Id [X ] = X
9
+ type TRgb = Id [Inner .Rgb ]
10
+
11
+ val ok = new Inner .Rgb ()
12
+ val crash = new Id [Inner .Rgb ]
You can’t perform that action at this time.
0 commit comments