Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion tests/explicit-nulls/flexible-unpickle/Flexible_2.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unsafeNulls.Foo.*
import unsafeNulls.Unsafe_1
import unsafeNulls.{A, B, C}
import unsafeNulls.{A, B, C, F, G, H, I, J, L, M}
import scala.reflect.Selectable.reflectiveSelectable

class Inherit_1 extends Unsafe_1 {
Expand Down Expand Up @@ -31,6 +31,9 @@ class Inherit_4 extends Unsafe_1 {

case class cc()

class K(val b: String) extends J(b) {
}

@main
def Flexible_2() =
val s2: String | Null = "foo"
Expand Down Expand Up @@ -66,3 +69,31 @@ def Flexible_2() =
val constructorTest = new Unsafe_1(null)
val member: String = constructorTest.member
constructorTest.member = null

bar match {
case str @ null: String => ()
case other => ()
}

val f = new F(null, G(12))
val F(x, y) = f

val g: (List[F] | String | List[Int]) = F.many
F.many = null :: null :: Nil
F.many = null

val h: H { val s: String } = new H { override val s: String = "foo" }

val jBox: I[J] = new I(new J(null))
val kBox: I[K] = new I(new K("foo"))

val box: I[J] = kBox

val jBox2: L[J] = new L[J](j => ())
val kBox2: L[K] = new L[K](k => ())

val box2: L[K] = jBox2
val box3: I[J | Null] = box

val m: String = M.test(null)

29 changes: 28 additions & 1 deletion tests/explicit-nulls/flexible-unpickle/Unsafe_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ trait C {
var stringC: String
}


object Foo {
extension (c: C)
def reverse: String = c.stringC.reverse
Expand All @@ -45,4 +46,30 @@ object Foo {
var singleton: bar.type = bar
var intersection: A & B = ???
var union: A | B = ???
}
}

class F(var x: String, var y: G)

class G(var z: Int)

object F {
def unapply(f: F): (String, G) = (f.x, f.y)
var many: (List[F] | String | List[Int]) = null
}

class H {
val s: String = null
}

class I[+A](val value: A)

class J(val a: String) {}

class L[-A](f: A => Unit)

class M {}

object M {
def test(input: => String): String = "foo " + input
}