aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala4
-rw-r--r--test/dotc/tests.scala3
-rw-r--r--tests/neg/i1050.scala4
-rw-r--r--tests/neg/i1050a.scala29
4 files changed, 36 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 98def3071..0b18a29c4 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -525,7 +525,9 @@ object SymDenotations {
/** Is this a denotation of a realizable term (or an arbitrary type)? */
final def isRealizable(implicit ctx: Context) =
is(Stable) || isType || {
- val isRealizable = !is(Lazy, butNot = Module) || ctx.realizability(info) == TypeOps.Realizable
+ val isRealizable =
+ !is(Lazy, butNot = Module) ||
+ is(Final) && ctx.realizability(info) == TypeOps.Realizable
isRealizable && { setFlag(Stable); true }
}
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index 1c62ed96d..689f92b04 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -162,7 +162,8 @@ class tests extends CompilerTest {
@Test def neg_i803 = compileFile(negDir, "i803", xerrors = 2)
@Test def neg_i866 = compileFile(negDir, "i866", xerrors = 2)
@Test def neg_i974 = compileFile(negDir, "i974", xerrors = 2)
- @Test def neg_i1050 = compileFile(negDir, "i1050", xerrors = 3)
+ @Test def neg_i1050 = compileFile(negDir, "i1050", xerrors = 5)
+ @Test def neg_i1050a = compileFile(negDir, "i1050a", xerrors = 2)
@Test def neg_moduleSubtyping = compileFile(negDir, "moduleSubtyping", xerrors = 4)
@Test def neg_escapingRefs = compileFile(negDir, "escapingRefs", xerrors = 2)
@Test def neg_instantiateAbstract = compileFile(negDir, "instantiateAbstract", xerrors = 8)
diff --git a/tests/neg/i1050.scala b/tests/neg/i1050.scala
index bc906f4f4..99d81c317 100644
--- a/tests/neg/i1050.scala
+++ b/tests/neg/i1050.scala
@@ -39,7 +39,7 @@ object Tiark1 {
trait A { type L <: Nothing }
trait B { type L >: Any}
trait U {
- val p: B
+ lazy val p: B
def brand(x: Any): p.L = x // error: not final
}
trait V extends U {
@@ -53,7 +53,7 @@ object Tiark2 {
trait B { type L >: Any}
trait U {
type X <: B
- val p: X
+ lazy val p: X
def brand(x: Any): p.L = x // error: not final
}
trait V extends U {
diff --git a/tests/neg/i1050a.scala b/tests/neg/i1050a.scala
new file mode 100644
index 000000000..47e2f0c59
--- /dev/null
+++ b/tests/neg/i1050a.scala
@@ -0,0 +1,29 @@
+object Tiark1 {
+ trait A { type L <: Nothing }
+ trait B { type L >: Any}
+ trait U {
+ val p: B
+ def brand(x: Any): p.L = x // error: not final
+ }
+ trait V extends U {
+ lazy val p: A & B = ???
+ }
+ val v = new V {}
+ v.brand("boom!")
+}
+object Tiark2 {
+ trait A { type L <: Nothing }
+ trait B { type L >: Any}
+ trait U {
+ type X <: B
+ val p: X
+ def brand(x: Any): p.L = x // error: not final
+ }
+ trait V extends U {
+ type X = B & A
+ lazy val p: X = ???
+ }
+ val v = new V {}
+ v.brand("boom!"): Nothing
+}
+