aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/i1047.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-01-29 23:46:00 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-09 09:40:52 +0100
commit41f056750990a2e6391eec3436077715041d2b8a (patch)
treeede383d5ec756b7a391e747eac472a1dc8f77755 /tests/pos/i1047.scala
parent633e2ebfd42af65f8324aec87a2444bb9cec5eff (diff)
downloaddotty-41f056750990a2e6391eec3436077715041d2b8a.tar.gz
dotty-41f056750990a2e6391eec3436077715041d2b8a.tar.bz2
dotty-41f056750990a2e6391eec3436077715041d2b8a.zip
Use isRealizable to identify stable prefixes
Replaces isVolatile, which is too weak (and more complicated). Backwards compatibility with Scala2 is ensured by dropping the requirement in Scala2 mode. Fixes #1047, which now compiles without inifinite recursion.
Diffstat (limited to 'tests/pos/i1047.scala')
-rw-r--r--tests/pos/i1047.scala31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/pos/i1047.scala b/tests/pos/i1047.scala
new file mode 100644
index 000000000..0f9b54135
--- /dev/null
+++ b/tests/pos/i1047.scala
@@ -0,0 +1,31 @@
+package hello
+
+object world extends App {
+ println("hello dotty!")
+
+ trait AnimalPackage {
+ type Animal <: AnimalU
+ type AnimalU = { val age: Int }
+ def newAnimal(a: AnimalU): Animal
+ def newSubAnimal[T](a: AnimalU & T): Animal & T
+ }
+ val p: AnimalPackage = new AnimalPackage { p =>
+ type Animal = AnimalU
+ override def newAnimal(a: AnimalU): Animal = a
+ override def newSubAnimal[T](a: AnimalU & T): Animal & T = a
+ }
+ val lambda: p.Animal = p.newAnimal(new { val age = 1 })
+ trait CatPackage { pc =>
+ type Cat <: p.Animal & pc.CatDelta
+ type CatDelta = { val meow: Int }
+ type CatU = p.AnimalU & pc.CatDelta
+ def newCat(c: CatU): Cat
+ def newSubCat[T](c: CatU & T): Cat & T
+ }
+ val pc: CatPackage = new CatPackage { pc =>
+ type Cat = p.Animal & pc.CatDelta
+ def newCat(c: CatU): Cat = p.newSubAnimal[pc.CatDelta](c)
+ def newSubCat[T](c: CatU & T): Cat & T = p.newSubAnimal[pc.CatDelta & T](c)
+ }
+ val felix: pc.Cat = pc.newCat(new { val age = 1; val meow = 2 })
+}