File tree 1 file changed +22
-0
lines changed
compiler/test/dotty/tools/backend/jvm 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,28 @@ class TestBCode extends DottyBytecodeTest {
118
118
}
119
119
}
120
120
121
+ @ Test def switchOnStrings = {
122
+ val source =
123
+ """
124
+ |object Foo {
125
+ | import scala.annotation.switch
126
+ | def foo(s: String, b: Boolean) = (s: @switch) match {
127
+ | case "AaAa" => println(3)
128
+ | case "BBBB" | "c" if b => println(2)
129
+ | case "D" | "E" => println(1)
130
+ | case _ => println(0)
131
+ | }
132
+ |}
133
+ """ .stripMargin
134
+
135
+ checkBCode(source) { dir =>
136
+ val moduleIn = dir.lookupName(" Foo$.class" , directory = false )
137
+ val moduleNode = loadClassNode(moduleIn.input)
138
+ val methodNode = getMethod(moduleNode, " foo" )
139
+ assert(verifySwitch(methodNode))
140
+ }
141
+ }
142
+
121
143
@ Test def matchWithDefaultNoThrowMatchError = {
122
144
val source =
123
145
""" class Test {
You can’t perform that action at this time.
0 commit comments