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 {
160
160
case tp : AnnotatedType => mapOver(tp)
161
161
case tp : OrType => mapOver(tp)
162
162
case tp : MatchType => mapOver(tp)
163
+ case tp : RefinedType => nullify(mapOver(tp))
163
164
case _ => tp
164
165
}
165
166
}
Original file line number Diff line number Diff line change 1
1
import unsafeNulls .Foo .*
2
2
import unsafeNulls .Unsafe_1
3
+ import unsafeNulls .{A , B , C }
4
+ import scala .reflect .Selectable .reflectiveSelectable
3
5
4
6
class Inherit_1 extends Unsafe_1 {
5
7
override def foo (s : String ): String = s
@@ -37,4 +39,30 @@ def Flexible_2() =
37
39
unsafe.foo(" " )
38
40
unsafe.foo(null )
39
41
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 1
1
package unsafeNulls
2
2
3
3
class Unsafe_1 {
4
+
5
+ def this (s : String ) = {
6
+ this ()
7
+ ???
8
+ }
9
+
4
10
def foo (s : String ): String = {
5
11
if (s == null ) then " nullString"
6
12
else s
@@ -13,14 +19,30 @@ class Unsafe_1 {
13
19
}
14
20
def bar3 [T <: Function1 [String ,String ]](g : T ): T = g
15
21
def bar4 [HK [_]](i : String ): HK [String ] = ???
22
+
23
+ var member : String = ???
16
24
}
17
25
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
+ }
21
33
34
+ trait C {
35
+ var stringC : String
22
36
}
23
37
24
- class Constructors {
38
+ object Foo {
39
+ extension (c : C )
40
+ def reverse : String = c.stringC.reverse
25
41
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 = ???
26
48
}
You can’t perform that action at this time.
0 commit comments