File tree 2 files changed +17
-1
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ class CheckRealizable(implicit ctx: Context) {
68
68
def realizability (tp : Type ): Realizability = tp.dealias match {
69
69
case tp : TermRef =>
70
70
val sym = tp.symbol
71
+ lazy val tpInfoRealizable = realizability(tp.info)
71
72
if (sym.is(Stable )) realizability(tp.prefix)
72
73
else {
73
74
val r =
@@ -80,10 +81,12 @@ class CheckRealizable(implicit ctx: Context) {
80
81
else
81
82
// otherwise we need to look at the info to determine realizability
82
83
// roughly: it's realizable if the info does not have bad bounds
83
- realizability(tp.info) .mapError(r => new ProblemInUnderlying (tp, r))
84
+ tpInfoRealizable .mapError(r => new ProblemInUnderlying (tp, r))
84
85
r andAlso {
85
86
if (sym.isStable) sym.setFlag(Stable ) // it's known to be stable and realizable
86
87
realizability(tp.prefix)
88
+ } mapError { r =>
89
+ if (tp.info.isStable && tpInfoRealizable == Realizable ) Realizable else r
87
90
}
88
91
}
89
92
case _ : SingletonType | NoPrefix =>
Original file line number Diff line number Diff line change
1
+ object Foo {
2
+ val x = new Object
3
+
4
+ class A (var y : x.type )
5
+
6
+ val a = new A (x)
7
+
8
+ val y : a.y.type = x
9
+ // 1 |val y: a.y.type = x
10
+ // | ^
11
+ // | Object(x)(a.y) is not a legal path
12
+ // | since it refers to nonfinal variable y
13
+ }
You can’t perform that action at this time.
0 commit comments