@@ -8,6 +8,8 @@ import scala.tools.asm.Opcodes._
88class ArrayApplyOptTest extends DottyBytecodeTest {
99 import ASMConverters ._
1010
11+ // FIXME: Re-enable IArray bytecode tests (requires updated reference compiler)
12+ // Also change: library/src/scala/IArray.scala
1113 @ Test def testArrayEmptyGenericApply = {
1214 test(" Array[String]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " java/lang/String" ), Op (POP ), Op (RETURN )))
1315 test(" Array[Unit]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " scala/runtime/BoxedUnit" ), Op (POP ), Op (RETURN )))
@@ -22,18 +24,18 @@ class ArrayApplyOptTest extends DottyBytecodeTest {
2224 test(" Array[Char]()" , newArray0Opcodes(T_CHAR ))
2325 test(" Array[T]()" , newArray0Opcodes(T_INT ))
2426
25- test(" IArray[String]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " java/lang/String" ), TypeOp (CHECKCAST , " [Ljava/lang/String;" ), Op (POP ), Op (RETURN )))
26- test(" IArray[Unit]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " scala/runtime/BoxedUnit" ), TypeOp (CHECKCAST , " [Lscala/runtime/BoxedUnit;" ), Op (POP ), Op (RETURN )))
27- test(" IArray[Object]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " java/lang/Object" ), TypeOp (CHECKCAST , " [Ljava/lang/Object;" ), Op (POP ), Op (RETURN )))
28- test(" IArray[Boolean]()" , newArray0Opcodes(T_BOOLEAN , TypeOp (CHECKCAST , " [Z" ) :: Nil ))
29- test(" IArray[Byte]()" , newArray0Opcodes(T_BYTE , TypeOp (CHECKCAST , " [B" ) :: Nil ))
30- test(" IArray[Short]()" , newArray0Opcodes(T_SHORT , TypeOp (CHECKCAST , " [S" ) :: Nil ))
31- test(" IArray[Int]()" , newArray0Opcodes(T_INT , TypeOp (CHECKCAST , " [I" ) :: Nil ))
32- test(" IArray[Long]()" , newArray0Opcodes(T_LONG , TypeOp (CHECKCAST , " [J" ) :: Nil ))
33- test(" IArray[Float]()" , newArray0Opcodes(T_FLOAT , TypeOp (CHECKCAST , " [F" ) :: Nil ))
34- test(" IArray[Double]()" , newArray0Opcodes(T_DOUBLE , TypeOp (CHECKCAST , " [D" ) :: Nil ))
35- test(" IArray[Char]()" , newArray0Opcodes(T_CHAR , TypeOp (CHECKCAST , " [C" ) :: Nil ))
36- test(" IArray[T]()" , newArray0Opcodes(T_INT , TypeOp (CHECKCAST , " [I" ) :: Nil ))
27+ // test("IArray[String]()", List(Op(ICONST_0), TypeOp(ANEWARRAY, "java/lang/String"), TypeOp(CHECKCAST, "[Ljava/lang/String;"), Op(POP), Op(RETURN)))
28+ // test("IArray[Unit]()", List(Op(ICONST_0), TypeOp(ANEWARRAY, "scala/runtime/BoxedUnit"), TypeOp(CHECKCAST, "[Lscala/runtime/BoxedUnit;"), Op(POP), Op(RETURN)))
29+ // test("IArray[Object]()", List(Op(ICONST_0), TypeOp(ANEWARRAY, "java/lang/Object"), TypeOp(CHECKCAST, "[Ljava/lang/Object;"), Op(POP), Op(RETURN)))
30+ // test("IArray[Boolean]()", newArray0Opcodes(T_BOOLEAN, TypeOp(CHECKCAST, "[Z") :: Nil))
31+ // test("IArray[Byte]()", newArray0Opcodes(T_BYTE, TypeOp(CHECKCAST, "[B") :: Nil))
32+ // test("IArray[Short]()", newArray0Opcodes(T_SHORT, TypeOp(CHECKCAST, "[S") :: Nil))
33+ // test("IArray[Int]()", newArray0Opcodes(T_INT, TypeOp(CHECKCAST, "[I") :: Nil))
34+ // test("IArray[Long]()", newArray0Opcodes(T_LONG, TypeOp(CHECKCAST, "[J") :: Nil))
35+ // test("IArray[Float]()", newArray0Opcodes(T_FLOAT, TypeOp(CHECKCAST, "[F") :: Nil))
36+ // test("IArray[Double]()", newArray0Opcodes(T_DOUBLE, TypeOp(CHECKCAST, "[D") :: Nil))
37+ // test("IArray[Char]()", newArray0Opcodes(T_CHAR, TypeOp(CHECKCAST, "[C") :: Nil))
38+ // test("IArray[T]()", newArray0Opcodes(T_INT, TypeOp(CHECKCAST, "[I") :: Nil))
3739 }
3840
3941 @ Test def testArrayGenericApply = {
@@ -44,90 +46,90 @@ class ArrayApplyOptTest extends DottyBytecodeTest {
4446
4547 def opCodes2 (tpe : String ) =
4648 List (Op (ICONST_2 ), TypeOp (ANEWARRAY , tpe), Op (DUP ), Op (ICONST_0 ), Ldc (LDC , " a" ), Op (AASTORE ), Op (DUP ), Op (ICONST_1 ), Ldc (LDC , " b" ), Op (AASTORE ), TypeOp (CHECKCAST , s " [L $tpe; " ), Op (POP ), Op (RETURN ))
47- test(""" IArray("a", "b")""" , opCodes2(" java/lang/String" ))
48- test(""" IArray[Object]("a", "b")""" , opCodes2(" java/lang/Object" ))
49+ // test("""IArray("a", "b")""", opCodes2("java/lang/String"))
50+ // test("""IArray[Object]("a", "b")""", opCodes2("java/lang/Object"))
4951 }
5052
5153 @ Test def testArrayApplyBoolean = {
5254 val init = List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (BASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_0 ), Op (BASTORE ))
5355 test(" Array(true, false)" , newArray2Opcodes(T_BOOLEAN , init))
54- test(" IArray(true, false)" , newArray2Opcodes(T_BOOLEAN , init :+ TypeOp (CHECKCAST , " [Z" )))
56+ // test("IArray(true, false)", newArray2Opcodes(T_BOOLEAN, init :+ TypeOp(CHECKCAST, "[Z")))
5557 }
5658
5759 @ Test def testArrayApplyByte = {
5860 val init = List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (BASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_2 ), Op (BASTORE ))
5961 test(" Array[Byte](1, 2)" , newArray2Opcodes(T_BYTE , init))
60- test(" IArray[Byte](1, 2)" , newArray2Opcodes(T_BYTE , init :+ TypeOp (CHECKCAST , " [B" )))
62+ // test("IArray[Byte](1, 2)", newArray2Opcodes(T_BYTE, init :+ TypeOp(CHECKCAST, "[B")))
6163 }
6264
6365 @ Test def testArrayApplyShort = {
6466 val init = List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (SASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_2 ), Op (SASTORE ))
6567 test(" Array[Short](1, 2)" , newArray2Opcodes(T_SHORT , init))
66- test(" IArray[Short](1, 2)" , newArray2Opcodes(T_SHORT , init :+ TypeOp (CHECKCAST , " [S" )))
68+ // test("IArray[Short](1, 2)", newArray2Opcodes(T_SHORT, init :+ TypeOp(CHECKCAST, "[S")))
6769 }
6870
6971 @ Test def testArrayApplyInt = {
7072 val init = List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (IASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_2 ), Op (IASTORE ))
7173 test(" Array(1, 2)" , newArray2Opcodes(T_INT , init))
72- test(" IArray(1, 2)" , newArray2Opcodes(T_INT , init :+ TypeOp (CHECKCAST , " [I" )))
74+ // test("IArray(1, 2)", newArray2Opcodes(T_INT, init :+ TypeOp(CHECKCAST, "[I")))
7375
7476 val init2 = List (Op (DUP ), Op (ICONST_0 ), Field (GETSTATIC , " Foo$" , " MODULE$" , " LFoo$;" ), Invoke (INVOKEVIRTUAL , " Foo$" , " t" , " ()I" , false ), Op (IASTORE ), Op (DUP ), Op (ICONST_1 ), Field (GETSTATIC , " Foo$" , " MODULE$" , " LFoo$;" ), Invoke (INVOKEVIRTUAL , " Foo$" , " t" , " ()I" , false ), Op (IASTORE ))
7577 test(""" Array[T](t, t)""" , newArray2Opcodes(T_INT , init2))
76- test(""" IArray[T](t, t)""" , newArray2Opcodes(T_INT , init2 :+ TypeOp (CHECKCAST , " [I" )))
78+ // test("""IArray[T](t, t)""", newArray2Opcodes(T_INT, init2 :+ TypeOp(CHECKCAST, "[I")))
7779 }
7880
7981 @ Test def testArrayApplyLong = {
8082 val init = List (Op (DUP ), Op (ICONST_0 ), Ldc (LDC , 2 ), Op (LASTORE ), Op (DUP ), Op (ICONST_1 ), Ldc (LDC , 3 ), Op (LASTORE ))
8183 test(" Array(2L, 3L)" , newArray2Opcodes(T_LONG , init))
82- test(" IArray(2L, 3L)" , newArray2Opcodes(T_LONG , init :+ TypeOp (CHECKCAST , " [J" )))
84+ // test("IArray(2L, 3L)", newArray2Opcodes(T_LONG, init :+ TypeOp(CHECKCAST, "[J")))
8385 }
8486
8587 @ Test def testArrayApplyFloat = {
8688 val init = List (Op (DUP ), Op (ICONST_0 ), Ldc (LDC , 2.1f ), Op (FASTORE ), Op (DUP ), Op (ICONST_1 ), Ldc (LDC , 3.1f ), Op (FASTORE ))
8789 test(" Array(2.1f, 3.1f)" , newArray2Opcodes(T_FLOAT , init))
88- test(" IArray(2.1f, 3.1f)" , newArray2Opcodes(T_FLOAT , init :+ TypeOp (CHECKCAST , " [F" )))
90+ // test("IArray(2.1f, 3.1f)", newArray2Opcodes(T_FLOAT, init :+ TypeOp(CHECKCAST, "[F")))
8991 }
9092
9193 @ Test def testArrayApplyDouble = {
9294 val init = List (Op (DUP ), Op (ICONST_0 ), Ldc (LDC , 2.2d ), Op (DASTORE ), Op (DUP ), Op (ICONST_1 ), Ldc (LDC , 3.2d ), Op (DASTORE ))
9395 test(" Array(2.2d, 3.2d)" , newArray2Opcodes(T_DOUBLE , init))
94- test(" IArray(2.2d, 3.2d)" , newArray2Opcodes(T_DOUBLE , init :+ TypeOp (CHECKCAST , " [D" )))
96+ // test("IArray(2.2d, 3.2d)", newArray2Opcodes(T_DOUBLE, init :+ TypeOp(CHECKCAST, "[D")))
9597 }
9698
9799 @ Test def testArrayApplyChar = {
98100 val init = List (Op (DUP ), Op (ICONST_0 ), IntOp (BIPUSH , 120 ), Op (CASTORE ), Op (DUP ), Op (ICONST_1 ), IntOp (BIPUSH , 121 ), Op (CASTORE ))
99101 test(" Array('x', 'y')" , newArray2Opcodes(T_CHAR , init))
100- test(" IArray('x', 'y')" , newArray2Opcodes(T_CHAR , init :+ TypeOp (CHECKCAST , " [C" )))
102+ // test("IArray('x', 'y')", newArray2Opcodes(T_CHAR, init :+ TypeOp(CHECKCAST, "[C")))
101103 }
102104
103105 @ Test def testArrayApplyUnit = {
104106 test(" Array[Unit]((), ())" , List (Op (ICONST_2 ), TypeOp (ANEWARRAY , " scala/runtime/BoxedUnit" ), Op (DUP ),
105107 Op (ICONST_0 ), Field (GETSTATIC , " scala/runtime/BoxedUnit" , " UNIT" , " Lscala/runtime/BoxedUnit;" ), Op (AASTORE ), Op (DUP ),
106108 Op (ICONST_1 ), Field (GETSTATIC , " scala/runtime/BoxedUnit" , " UNIT" , " Lscala/runtime/BoxedUnit;" ), Op (AASTORE ), Op (POP ), Op (RETURN )))
107- test(" IArray[Unit]((), ())" , List (Op (ICONST_2 ), TypeOp (ANEWARRAY , " scala/runtime/BoxedUnit" ), Op (DUP ),
108- Op (ICONST_0 ), Field (GETSTATIC , " scala/runtime/BoxedUnit" , " UNIT" , " Lscala/runtime/BoxedUnit;" ), Op (AASTORE ), Op (DUP ),
109- Op (ICONST_1 ), Field (GETSTATIC , " scala/runtime/BoxedUnit" , " UNIT" , " Lscala/runtime/BoxedUnit;" ), Op (AASTORE ), TypeOp (CHECKCAST , " [Lscala/runtime/BoxedUnit;" ), Op (POP ), Op (RETURN )))
109+ // test("IArray[Unit]((), ())", List(Op(ICONST_2), TypeOp(ANEWARRAY, "scala/runtime/BoxedUnit"), Op(DUP),
110+ // Op(ICONST_0), Field(GETSTATIC, "scala/runtime/BoxedUnit", "UNIT", "Lscala/runtime/BoxedUnit;"), Op(AASTORE), Op(DUP),
111+ // Op(ICONST_1), Field(GETSTATIC, "scala/runtime/BoxedUnit", "UNIT", "Lscala/runtime/BoxedUnit;"), Op(AASTORE), TypeOp(CHECKCAST, "[Lscala/runtime/BoxedUnit;"), Op(POP), Op(RETURN)))
110112 }
111113
112114 @ Test def testArrayInlined = test(
113115 """ {
114- | inline def array(xs: => Int*): Array[Int] = Array(xs: _*)
116+ | inline def array(inline xs: Int*): Array[Int] = Array(xs: _*)
115117 | array(1, 2)
116118 |}""" .stripMargin,
117119 newArray2Opcodes(T_INT , List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (IASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_2 ), Op (IASTORE ), TypeOp (CHECKCAST , " [I" )))
118120 )
119121
120122 @ Test def testArrayInlined2 = test(
121123 """ {
122- | inline def array(x: => Int, xs: => Int*): Array[Int] = Array(x, xs: _*)
124+ | inline def array(inline x: Int, inline xs: Int*): Array[Int] = Array(x, xs: _*)
123125 | array(1, 2)
124126 |}""" .stripMargin,
125127 newArray2Opcodes(T_INT , List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (IASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_2 ), Op (IASTORE )))
126128 )
127129
128130 @ Test def testArrayInlined3 = test(
129131 """ {
130- | inline def array[T](xs: => T*)(given ct: => scala.reflect.ClassTag[T]): Array[T] = Array(xs: _*)
132+ | inline def array[T](inline xs: T*)(given inline ct: scala.reflect.ClassTag[T]): Array[T] = Array(xs: _*)
131133 | array(1, 2)
132134 |}""" .stripMargin,
133135 newArray2Opcodes(T_INT , List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (IASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_2 ), Op (IASTORE ), TypeOp (CHECKCAST , " [I" )))
0 commit comments