Skip to content

Commit 79a1a52

Browse files
authored
Merge pull request #1 from SuperCl4sh/flexibleunpickledev
Add more tests
2 parents a2dfe25 + 641eb52 commit 79a1a52

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

tests/explicit-nulls/flexible-unpickle/Flexible_2.scala

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unsafeNulls.Foo.*
22
import unsafeNulls.Unsafe_1
3-
import unsafeNulls.{A, B, C}
3+
import unsafeNulls.{A, B, C, F, G, H, I, J, L, M}
44
import scala.reflect.Selectable.reflectiveSelectable
55

66
class Inherit_1 extends Unsafe_1 {
@@ -31,6 +31,9 @@ class Inherit_4 extends Unsafe_1 {
3131

3232
case class cc()
3333

34+
class K(val b: String) extends J(b) {
35+
}
36+
3437
@main
3538
def Flexible_2() =
3639
val s2: String | Null = "foo"
@@ -66,3 +69,31 @@ def Flexible_2() =
6669
val constructorTest = new Unsafe_1(null)
6770
val member: String = constructorTest.member
6871
constructorTest.member = null
72+
73+
bar match {
74+
case str @ null: String => ()
75+
case other => ()
76+
}
77+
78+
val f = new F(null, G(12))
79+
val F(x, y) = f
80+
81+
val g: (List[F] | String | List[Int]) = F.many
82+
F.many = null :: null :: Nil
83+
F.many = null
84+
85+
val h: H { val s: String } = new H { override val s: String = "foo" }
86+
87+
val jBox: I[J] = new I(new J(null))
88+
val kBox: I[K] = new I(new K("foo"))
89+
90+
val box: I[J] = kBox
91+
92+
val jBox2: L[J] = new L[J](j => ())
93+
val kBox2: L[K] = new L[K](k => ())
94+
95+
val box2: L[K] = jBox2
96+
val box3: I[J | Null] = box
97+
98+
val m: String = M.test(null)
99+

tests/explicit-nulls/flexible-unpickle/Unsafe_1.scala

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ trait C {
3535
var stringC: String
3636
}
3737

38+
3839
object Foo {
3940
extension (c: C)
4041
def reverse: String = c.stringC.reverse
@@ -45,4 +46,30 @@ object Foo {
4546
var singleton: bar.type = bar
4647
var intersection: A & B = ???
4748
var union: A | B = ???
48-
}
49+
}
50+
51+
class F(var x: String, var y: G)
52+
53+
class G(var z: Int)
54+
55+
object F {
56+
def unapply(f: F): (String, G) = (f.x, f.y)
57+
var many: (List[F] | String | List[Int]) = null
58+
}
59+
60+
class H {
61+
val s: String = null
62+
}
63+
64+
class I[+A](val value: A)
65+
66+
class J(val a: String) {}
67+
68+
class L[-A](f: A => Unit)
69+
70+
class M {}
71+
72+
object M {
73+
def test(input: => String): String = "foo " + input
74+
}
75+

0 commit comments

Comments
 (0)