Skip to content

Commit 397dfd6

Browse files
committed
New pos tests
Some of them were moved from disabled after verifiying that they compile now.
1 parent 20f6e9d commit 397dfd6

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed

tests/pos/intersection.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
object intersection {
2+
3+
class A
4+
class B
5+
6+
val x: A => Unit = ???
7+
val y: B => Unit = ???
8+
9+
val z = if (???) x else y
10+
11+
val a: A & B => Unit = z
12+
val b: (A => Unit) | (B => Unit) = z
13+
14+
15+
16+
17+
type needsA = A => Nothing
18+
type needsB = B => Nothing
19+
}

tests/pos/jon.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This one blows up with a huge type in Scala 2.
2+
// Reported by Jon Pretty in his talk on Scala type inference.
3+
object Test {
4+
5+
val x = List(List, Vector)
6+
7+
val y: List[scala.collection.generic.SeqFactory] = x
8+
}

tests/pos/pets.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Representing the current type
2+
trait Pet {
3+
type This <: Pet
4+
def name: String
5+
def renamed(newName: String): This
6+
}
7+
8+
case class Fish(name: String, age: Int) extends Pet {
9+
type This = Fish
10+
def renamed(newName: String): Fish = copy(name = newName)
11+
}
12+
13+
case class Kitty(name: String, age: Int) extends Pet {
14+
type This = Kitty
15+
def renamed(newName: String): Kitty = copy(name = newName)
16+
}
17+
18+
object Test {
19+
def esquire[A <: Pet](a: A): a.This = a.renamed(a.name + ", Esq.")
20+
val f: Fish = esquire(new Fish("bob", 22))
21+
}

tests/pos/sort.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object sorting {
2+
3+
val xs: Array[String] = ???
4+
5+
java.util.Arrays.sort(xs, ???)
6+
7+
}

tests/pos/staleSymbol.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object intersection {
2+
3+
class A
4+
class B
5+
6+
val x: A => Unit = ???
7+
}

0 commit comments

Comments
 (0)