blob: 83cabf85654f6c57158b80615c3c50c907b3161a (
plain) (
blame)
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
|
object Test extends dotty.runtime.LegacyApp {
def testBothReachable(): Unit = {
val i = util.Random.nextInt
val x = if (i % 2 == 0) null else "good"
val y = if (x == null) "good" else x + ""
println(s"testBothReachable: $y")
}
def testOneReachable(): Unit = {
val i = 1
val x = if (i != 1) null else "good"
val y = if (x == null) "good" else x + ""
println(s"testOneReachable: $y")
}
def testAllReachable(): Unit = {
val i = util.Random.nextInt
val y = (i % 2) match {
case 0 => "good"
case 1 => "good"
case _ => "good"
}
println(s"testAllReachable: $y")
}
def testOneUnreachable(): Unit = {
val i = util.Random.nextInt
val x = if (i % 2 == 0) {
1
} else {
2
}
val y = x match {
case 0 => "good"
case 1 => "good"
case _ => "good"
}
println(s"testOneUnreachable: $y")
}
def testDefaultUnreachable(): Unit = {
val i = util.Random.nextInt
val x = if (i % 2 == 0) {
1
} else {
2
}
val y = x match {
case 1 => "good"
case 2 => "good"
case _ => "good"
}
println(s"testDefaultUnreachable: $y")
}
testBothReachable()
testOneReachable()
testAllReachable()
testOneUnreachable()
testDefaultUnreachable()
}
|