forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
6314.scala
67 lines (56 loc) · 1.5 KB
/
6314.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
object Test1 {
// X, Y and Z are unrelated, Y is provably disjoint from Z, but X is not provably disjoint with either
trait X
class Y
class Z
trait Test {
type Type
// This is testing that both permutations of the types in a &
// are taken into account by the provablyDisjoint test
val i: Bar[Y & Type] = 1 // ok, disjoint from X & Z because Y and Z are disjoint
}
type Bar[A] = A match {
case X & Z => String
case Y => Int
}
}
object Test1Bis {
final class X
final class Y
trait Test {
type Type
// This is testing that both permutations of the types in a |
// are taken into account by the provablyDisjoint test
val i: Bar[Y | Type] = 1 // error
}
type Bar[A] = A match {
case X & Y => String
case Any => Int
}
}
object Test2 {
trait Wizzle[L <: Int & Singleton] {
type Bar[A] = A match {
case 0 => String
case L => Int
}
// This is testing that we don't make wrong assumptions about Singleton
def right(fa: Bar[L]): Int = fa // error
}
trait Wazzlo[L <: Int & AnyVal] {
type Bar[A] = A match {
case 0 => String
case L => Int
}
// This is testing that we don't make wrong assumptions about AnyVal
def right(fa: Bar[L]): Int = fa // error
}
trait Wuzzlu[L <: String & AnyRef] {
type Bar[A] = A match {
case "" => String
case L => Int
}
// This is testing that we don't make wrong assumptions about AnyRef
def right(fa: Bar[L]): Int = fa // error
}
}