Skip to content

Commit 084d4bd

Browse files
committed
Add missing test
1 parent 0669011 commit 084d4bd

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/neg/arrayclone-new.scala

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Run with -explaintypes to see information about shadowing failures
2+
import scala.reflect.{ClassTag, classTag}
3+
4+
object Test extends dotty.runtime.LegacyApp{
5+
ObjectArrayClone;
6+
PolymorphicArrayClone;
7+
}
8+
9+
object ObjectArrayClone{
10+
val it : Array[String] = Array("1", "0");
11+
val cloned = it.clone();
12+
assert(cloned.sameElements(it));
13+
cloned(0) = "0";
14+
assert(it(0) == "1")
15+
}
16+
17+
object PolymorphicArrayClone{
18+
def testIt[T](it : Array[T], one : T, zero : T) = {
19+
val cloned = it.clone();
20+
assert(cloned.sameElements(it));
21+
cloned(0) = zero;
22+
assert(it(0) == one)
23+
}
24+
25+
testIt(Array("one", "two"), "one", "two");
26+
27+
class Mangler[T: ClassTag](ts : T*){
28+
// this will always be a BoxedAnyArray even after we've unboxed its contents.
29+
val it = ts.toArray[T];
30+
}
31+
32+
val mangled = new Mangler[Int](0, 1);
33+
34+
val y : Array[Int] = mangled.it; // make sure it's unboxed
35+
36+
testIt(mangled.it, 0, 1);
37+
}
38+

0 commit comments

Comments
 (0)