Skip to content

Commit e1ba839

Browse files
authored
Merge pull request #5522 from abeln/prefix
Fix #5521: prefix not checked in realizability check
2 parents 5d1efe3 + 0eea5b3 commit e1ba839

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/CheckRealizable.scala

+5-3
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ class CheckRealizable(implicit ctx: Context) {
7474
else {
7575
val r =
7676
if (!sym.isStable) NotStable
77-
else if (!isLateInitialized(sym)) realizability(tp.prefix)
77+
else if (!isLateInitialized(sym)) Realizable
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+
r andAlso {
81+
sym.setFlag(Stable)
82+
realizability(tp.prefix)
83+
}
8284
}
8385
case _: SingletonType | NoPrefix =>
8486
Realizable

Diff for: tests/neg/i5521.scala

+12
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)