Skip to content

Commit 56af302

Browse files
committed
More test cases
1 parent 86450c3 commit 56af302

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

tests/neg/singletonOrs.scala

+28
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,31 @@ object Test {
44
def c: 1 | 2 = 1
55
def d: 1 = a // error
66
}
7+
8+
// Following examples are from issue #1551
9+
object Test2 {
10+
type ABC = 'A' | 'B' | 'C'
11+
type A2F = ABC | 'D' | 'E' | 'F'
12+
13+
def foo(x: A2F) = ()
14+
foo('F') // ok
15+
foo('G') // error
16+
}
17+
18+
object Get2As1 {
19+
class OrIntroFn[T, U, TU >: T|U]{
20+
type V = TU
21+
def tuToV(): (TU => V) = p => p
22+
}
23+
class Or11X[X] extends OrIntroFn[1&1, X, (1&1|X)]{
24+
def get2as11X:V = tuToV()(2) // error
25+
}
26+
class Or11Nothing extends Or11X[Nothing]
27+
def get2as1:1 = new Or11Nothing().get2as11X // error
28+
29+
def main(a:Array[String]) = {
30+
println(get2as1) // prints 2
31+
val one:1 = get2as1
32+
println(one) // prints 1
33+
}
34+
}

tests/pos/single-unions.scala

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@ object A {
22
val x1: 3 | 4 = 3
33
val x2: 3 | 4 = 4
44
val x3: 3 | 4 = if (???) 3 else 4
5-
}
5+
}
6+
7+
// The following example is from issue #1551
8+
object Test1 {
9+
sealed trait Fence[+T, +S]
10+
case object End extends Fence[Nothing, Nothing]
11+
case class Post[+T, +S](value: T, next: Panel[T, S] | End.type) extends Fence[T, S]
12+
case class Panel[+T, +S](value: S, next: Post[T, S]) extends Fence[T, S]
13+
14+
val fence = Post(1, Panel("two", Post(3, End)))
15+
}

0 commit comments

Comments
 (0)