aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/pos/intersection.scala19
-rw-r--r--tests/pos/jon.scala8
-rw-r--r--tests/pos/pets.scala21
-rw-r--r--tests/pos/sort.scala7
-rw-r--r--tests/pos/staleSymbol.scala7
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 = ???
+}