Skip to content

Commit 124f68b

Browse files
author
EnzeXing
committed
Added tests
1 parent f091c4e commit 124f68b

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

tests/init-global/pos/TypeCast1.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class A:
2+
class B(val b: Int)
3+
4+
object O:
5+
val o: A | Array[Int] = new Array[Int](10)
6+
o match
7+
case a: A => new a.B(10)
8+
case arr: Array[Int] => arr(5)
9+

tests/init-global/pos/TypeCast2.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class A:
2+
class B(val b: Int)
3+
4+
object O:
5+
val o: A | (Int => Int) = (x: Int) => x + 1
6+
o match
7+
case a: A => new a.B(10)
8+
case f: (_ => _) => f.asInstanceOf[Int => Int](5)
9+

tests/init-global/pos/TypeCast3.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class A:
2+
var x: Int = 10
3+
4+
object O:
5+
val o: A | (Int => Int) = (x: Int) => x + 1
6+
o match
7+
case a: A => a.x = 20
8+
case f: (_ => _) => f.asInstanceOf[Int => Int](5)

tests/init-global/pos/TypeCast4.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class A:
2+
var x: Int = 10
3+
4+
object O:
5+
val o: A | Array[Int] = new Array[Int](10)
6+
o match
7+
case a: A => a.x = 20
8+
case arr: Array[Int] => arr(5)
9+

0 commit comments

Comments
 (0)