Skip to content

Commit a24218a

Browse files
committed
Fix #5521: prefix not checked in realizability check
We were forgetting to check the prefix in the uncached case.
1 parent a64e083 commit a24218a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

compiler/src/dotty/tools/dotc/core/CheckRealizable.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ class CheckRealizable(implicit ctx: Context) {
7777
else if (!isLateInitialized(sym)) realizability(tp.prefix)
7878
else if (!sym.isEffectivelyFinal) new NotFinal(sym)
7979
else realizability(tp.info).mapError(r => new ProblemInUnderlying(tp.info, r))
80-
if (r == Realizable) sym.setFlag(Stable)
81-
r
80+
val r1 = if (r == Realizable) {
81+
sym.setFlag(Stable)
82+
realizability(tp.prefix)
83+
} else r
84+
r1
8285
}
8386
case _: SingletonType | NoPrefix =>
8487
Realizable

tests/neg/i5521.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Hello {
2+
class Foo {
3+
class Bar
4+
final lazy val s: Bar = ???
5+
}
6+
7+
lazy val foo: Foo = ???
8+
9+
val x: foo.s.type = ??? // error: `foo` must be final since it's a lazy val
10+
val x2: foo.s.type = ??? // error: `foo` must be final since it's a lazy val
11+
}
12+

0 commit comments

Comments
 (0)