Skip to content

Commit 5ef03c4

Browse files
committed
Add test for Array.ofDim
1 parent d514728 commit 5ef03c4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/test/DottyBytecodeTests.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,28 @@ class TestBCode extends DottyBytecodeTest {
8282
assert(verifySwitch(methodNode, shouldFail = true))
8383
}
8484
}
85+
86+
/** Make sure that creating multidim arrays reduces to "multinewarray"
87+
* instruction
88+
*/
89+
@Test def multidimArrays = {
90+
val source = """
91+
|object Arr {
92+
| def arr = Array.ofDim[Int](2, 1)
93+
|}""".stripMargin
94+
checkBCode(source) { dir =>
95+
val moduleIn = dir.lookupName("Arr$.class", directory = false)
96+
val moduleNode = loadClassNode(moduleIn.input)
97+
val method = getMethod(moduleNode, "arr")
98+
99+
val hadCorrectInstr =
100+
instructionsFromMethod(method)
101+
.collect { case x @ NewArray(op, _, dims) if op == 197 && dims == 2 => x }
102+
.length > 0
103+
104+
assert(hadCorrectInstr,
105+
"Did not contain \"multianewarray\" instruction in:\n" +
106+
instructionsFromMethod(method).mkString("\n"))
107+
}
108+
}
85109
}

0 commit comments

Comments
 (0)