File tree Expand file tree Collapse file tree 3 files changed +56
-5
lines changed
compiler/src/dotty/tools/dotc/core
tests/explicit-nulls/flexible-unpickle Expand file tree Collapse file tree 3 files changed +56
-5
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,7 @@ object ImplicitNullInterop {
160160 case tp : AnnotatedType => mapOver(tp)
161161 case tp : OrType => mapOver(tp)
162162 case tp : MatchType => mapOver(tp)
163+ case tp : RefinedType => nullify(mapOver(tp))
163164 case _ => tp
164165 }
165166 }
Original file line number Diff line number Diff line change 11import unsafeNulls .Foo .*
22import unsafeNulls .Unsafe_1
3+ import unsafeNulls .{A , B , C }
4+ import scala .reflect .Selectable .reflectiveSelectable
35
46class Inherit_1 extends Unsafe_1 {
57 override def foo (s : String ): String = s
@@ -37,4 +39,30 @@ def Flexible_2() =
3739 unsafe.foo(" " )
3840 unsafe.foo(null )
3941
40- val refinement = new Unsafe_1 {val b : String }
42+
43+ val a = refinement.b
44+ refinement.b = null
45+ val refinement2 : Unsafe_1 { var b : String } = refinement
46+ refinement = null
47+
48+ val singletonbar : bar.type = singleton
49+
50+ val extension : String = intersection.reverse
51+
52+ val stringA : String = intersection.stringA
53+ val stringB : String = intersection.stringB
54+ intersection.stringA = null
55+ intersection.stringB = null
56+
57+ val intersection2 : A & B = intersection
58+ intersection = null
59+
60+ val stringC : String = union.stringC
61+ union.stringC = null
62+
63+ val union2 : A | B = union
64+ union = null
65+
66+ val constructorTest = new Unsafe_1 (null )
67+ val member : String = constructorTest.member
68+ constructorTest.member = null
Original file line number Diff line number Diff line change 11package unsafeNulls
22
33class Unsafe_1 {
4+
5+ def this (s : String ) = {
6+ this ()
7+ ???
8+ }
9+
410 def foo (s : String ): String = {
511 if (s == null ) then " nullString"
612 else s
@@ -13,14 +19,30 @@ class Unsafe_1 {
1319 }
1420 def bar3 [T <: Function1 [String ,String ]](g : T ): T = g
1521 def bar4 [HK [_]](i : String ): HK [String ] = ???
22+
23+ var member : String = ???
1624}
1725
18- object Foo {
19- def bar = " bar!"
20- def id [T ](t : T ): T = t
26+ trait A extends C {
27+ var stringA : String
28+ }
29+
30+ trait B extends C {
31+ var stringB : String
32+ }
2133
34+ trait C {
35+ var stringC : String
2236}
2337
24- class Constructors {
38+ object Foo {
39+ extension (c : C )
40+ def reverse : String = c.stringC.reverse
2541
42+ val bar : String = null
43+ def id [T ](t : T ): T = t
44+ var refinement : Unsafe_1 { var b : String } = new Unsafe_1 { var b : String = " ???" }
45+ var singleton : bar.type = bar
46+ var intersection : A & B = ???
47+ var union : A | B = ???
2648}
You can’t perform that action at this time.
0 commit comments