diff options
author | Martin Odersky <odersky@gmail.com> | 2015-05-27 10:29:44 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-05-27 10:30:56 +0200 |
commit | 397dfd6d564b032e5f1d52dda015ffb4238a595f (patch) | |
tree | d0d2d4280ec1eac3978cd80a83751deee534bf1d /tests/pos | |
parent | 20f6e9d9efb6ece9a8844cfe011ac1cc663c378e (diff) | |
download | dotty-397dfd6d564b032e5f1d52dda015ffb4238a595f.tar.gz dotty-397dfd6d564b032e5f1d52dda015ffb4238a595f.tar.bz2 dotty-397dfd6d564b032e5f1d52dda015ffb4238a595f.zip |
New pos tests
Some of them were moved from disabled after verifiying that they compile now.
Diffstat (limited to 'tests/pos')
-rw-r--r-- | tests/pos/intersection.scala | 19 | ||||
-rw-r--r-- | tests/pos/jon.scala | 8 | ||||
-rw-r--r-- | tests/pos/pets.scala | 21 | ||||
-rw-r--r-- | tests/pos/sort.scala | 7 | ||||
-rw-r--r-- | tests/pos/staleSymbol.scala | 7 |
5 files changed, 62 insertions, 0 deletions
diff --git a/tests/pos/intersection.scala b/tests/pos/intersection.scala new file mode 100644 index 000000000..2b9f6c0b7 --- /dev/null +++ b/tests/pos/intersection.scala @@ -0,0 +1,19 @@ +object intersection { + + class A + class B + + val x: A => Unit = ??? + val y: B => Unit = ??? + + val z = if (???) x else y + + val a: A & B => Unit = z + val b: (A => Unit) | (B => Unit) = z + + + + + type needsA = A => Nothing + type needsB = B => Nothing +} diff --git a/tests/pos/jon.scala b/tests/pos/jon.scala new file mode 100644 index 000000000..d4ea74f02 --- /dev/null +++ b/tests/pos/jon.scala @@ -0,0 +1,8 @@ +// This one blows up with a huge type in Scala 2. +// Reported by Jon Pretty in his talk on Scala type inference. +object Test { + + val x = List(List, Vector) + + val y: List[scala.collection.generic.SeqFactory] = x +} diff --git a/tests/pos/pets.scala b/tests/pos/pets.scala new file mode 100644 index 000000000..e1d5df44e --- /dev/null +++ b/tests/pos/pets.scala @@ -0,0 +1,21 @@ +// Representing the current type +trait Pet { + type This <: Pet + def name: String + def renamed(newName: String): This +} + +case class Fish(name: String, age: Int) extends Pet { + type This = Fish + def renamed(newName: String): Fish = copy(name = newName) +} + +case class Kitty(name: String, age: Int) extends Pet { + type This = Kitty + def renamed(newName: String): Kitty = copy(name = newName) +} + +object Test { + def esquire[A <: Pet](a: A): a.This = a.renamed(a.name + ", Esq.") + val f: Fish = esquire(new Fish("bob", 22)) +} diff --git a/tests/pos/sort.scala b/tests/pos/sort.scala new file mode 100644 index 000000000..97ee3454d --- /dev/null +++ b/tests/pos/sort.scala @@ -0,0 +1,7 @@ +object sorting { + + val xs: Array[String] = ??? + + java.util.Arrays.sort(xs, ???) + +} diff --git a/tests/pos/staleSymbol.scala b/tests/pos/staleSymbol.scala new file mode 100644 index 000000000..310d87cb9 --- /dev/null +++ b/tests/pos/staleSymbol.scala @@ -0,0 +1,7 @@ +object intersection { + + class A + class B + + val x: A => Unit = ??? +} |