aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-01-31 17:04:02 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-09 09:43:06 +0100
commit0480cb2a5902b733145f54fdc238aba7b831396b (patch)
tree1ac631aae15344440b51562d35d09ce4032e13d0 /tests/neg
parent5fd2028931874291b3cf1b7efef4fed7119d9316 (diff)
downloaddotty-0480cb2a5902b733145f54fdc238aba7b831396b.tar.gz
dotty-0480cb2a5902b733145f54fdc238aba7b831396b.tar.bz2
dotty-0480cb2a5902b733145f54fdc238aba7b831396b.zip
Only final lazy vals can be paths.
Reason: They might be overridden by other lazy vals that are not realizable, and therefore risk creating bad bounds.
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/i1050.scala4
-rw-r--r--tests/neg/i1050a.scala29
2 files changed, 31 insertions, 2 deletions
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
+}
+