File tree 2 files changed +28
-10
lines changed
compiler/test/dotty/tools/backend/jvm
2 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package dotty.tools.backend.jvm
3
3
import org .junit .Assert ._
4
4
import org .junit .Test
5
5
6
+ import scala .tools .asm .Opcodes
7
+
6
8
class TestBCode extends DottyBytecodeTest {
7
9
import ASMConverters ._
8
10
@ Test def nullChecks = {
@@ -213,4 +215,30 @@ class TestBCode extends DottyBytecodeTest {
213
215
assert(! arrayWrapped, " Arrays should not be wrapped when passed to a Java varargs method\n " )
214
216
}
215
217
}
218
+
219
+ @ Test def efficientTryCases = {
220
+ val source =
221
+ """
222
+ |class Test {
223
+ | def test =
224
+ | try print("foo")
225
+ | catch {
226
+ | case _: scala.runtime.NonLocalReturnControl[_] => ()
227
+ | }
228
+ |}
229
+ """ .stripMargin
230
+
231
+ checkBCode(source) { dir =>
232
+ val moduleIn = dir.lookupName(" Test.class" , directory = false )
233
+ val moduleNode = loadClassNode(moduleIn.input)
234
+ val method = getMethod(moduleNode, " test" )
235
+
236
+ val hasInstanceof = instructionsFromMethod(method).exists {
237
+ case TypeOp (Opcodes .INSTANCEOF , _) => true
238
+ case _ => false
239
+ }
240
+
241
+ assert(! hasInstanceof, " Try case should not issue INSTANCEOF opcode\n " )
242
+ }
243
+ }
216
244
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments