blob: 82cca01c70a47db406b248e5eef2ad73a4486ab8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import scala.annotation.switch
class Foo extends AnyRef {
// TODO NEEDS MANUAL CHANGE (early initializers)
// BEGIN copied early initializers
final val b0 = 5
// END copied early initializers
final val b1 = 10
// Using the @switch annotation as a means of testing that the
// type inferred for b0 is Int(5) and not Int. Only in the former
// case can a switch be generated.
def f(p: Int) = (p: @switch) match {
case `b0` => 1
case `b1` => 2
case 15 => 3
case 20 => 4
case _ => 5
}
}
|