summaryrefslogtreecommitdiff
path: root/test/files/jvm/unreachable/Foo_1.scala
blob: 600b96bb18a651c793ea62813a63c2501a008cc1 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import scala.sys.error

class Foo_1 {
  def unreachableNormalExit: Int = {
    return 42
    0
  }

  def unreachableIf: Int = {
    return 42
    if (util.Random.nextInt % 2 == 0)
      0
    else
      1
  }

  def unreachableIfBranches: Int = {
    if (util.Random.nextInt % 2 == 0)
      return 42
    else
      return 42

    return 0
  }

  def unreachableOneLegIf: Int = {
    if (util.Random.nextInt % 2 == 0)
      return 42

    return 42
  }

  def unreachableLeftBranch: Int = {
    val result = if (util.Random.nextInt % 2 == 0)
      return 42
    else
      42

    return result
  }

  def unreachableRightBranch: Int = {
    val result = if (util.Random.nextInt % 2 == 0)
      42
    else
      return 42

    return result
  }

  def unreachableTryCatchFinally: Int = {
    return 42
    try {
      return 0
    } catch {
      case x: Throwable => return 1
    } finally {
      return 2
    }
    return 3
  }

  def unreachableAfterTry: Int = {
    try {
      return 42
    } catch {
      case x: Throwable => return 2
    }
    return 3
  }

  def unreachableAfterCatch: Int = {
    try {
      error("haha")
    } catch {
      case x: Throwable => return 42
    }
    return 3
  }

  def unreachableAfterFinally: Int = {
    try {
      return 1
    } catch {
      case x: Throwable => return 2
    } finally {
      return 42
    }
    return 3
  }

  def unreachableSwitch: Int = {
  	return 42
    val x = util.Random.nextInt % 2
    x match {
      case 0 => return 0
      case 1 => return 1
      case _ => error("wtf")
    }
    2
  }

  def unreachableAfterSwitch: Int = {
    val x = util.Random.nextInt % 2
    x match {
      case 0 => return 42
      case 1 => return 41 + x
      case _ => error("wtf")
    }
    2
  }
}