@@ -161,6 +161,42 @@ class ArrayApplyOptTest extends DottyBytecodeTest {
161
161
}
162
162
}
163
163
164
+ @ Test def emptyListApplyAvoidsIntermediateArray =
165
+ checkApplyAvoidsIntermediateArray(" EmptyList" ):
166
+ """ import scala.collection.immutable.Nil
167
+ |class Foo {
168
+ | def meth1: List[String] = List()
169
+ | def meth2: List[String] = Nil
170
+ |}
171
+ """ .stripMargin
172
+
173
+ @ Test def emptyRefListApplyAvoidsIntermediateArray =
174
+ checkApplyAvoidsIntermediateArray(" EmptyListOfRef" ):
175
+ """ import scala.collection.immutable.Nil
176
+ |class Foo {
177
+ | def meth1: List[String] = List[String]()
178
+ | def meth2: List[String] = Nil
179
+ |}
180
+ """ .stripMargin
181
+
182
+ @ Test def emptyPrimitiveListApplyAvoidsIntermediateArray =
183
+ checkApplyAvoidsIntermediateArray(" EmptyListOfInt" ):
184
+ """ import scala.collection.immutable.Nil
185
+ |class Foo {
186
+ | def meth1: List[Int] = List()
187
+ | def meth2: List[Int] = Nil
188
+ |}
189
+ """ .stripMargin
190
+
191
+ @ Test def primitiveListApplyAvoidsIntermediateArray =
192
+ checkApplyAvoidsIntermediateArray(" ListOfInt" ):
193
+ """ import scala.collection.immutable.{ ::, Nil }
194
+ |class Foo {
195
+ | def meth1: List[Int] = List(1, 2, 3)
196
+ | def meth2: List[Int] = new ::(1, new ::(2, new ::(3, Nil)))
197
+ |}
198
+ """ .stripMargin
199
+
164
200
@ Test def testListApplyAvoidsIntermediateArray = {
165
201
checkApplyAvoidsIntermediateArray(" List" ):
166
202
""" import scala.collection.immutable.{ ::, Nil }
0 commit comments