File tree Expand file tree Collapse file tree 5 files changed +62
-0
lines changed Expand file tree Collapse file tree 5 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ object sorting {
2+
3+ val xs : Array [String ] = ???
4+
5+ java.util.Arrays .sort(xs, ??? )
6+
7+ }
Original file line number Diff line number Diff line change 1+ object intersection {
2+
3+ class A
4+ class B
5+
6+ val x : A => Unit = ???
7+ }
You can’t perform that action at this time.
0 commit comments