-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit 9e88707
Apply flexible types to files compiled without explicit nulls (#23386)
A fixed version of #22473
This PR wraps the types of symbols from files compiled without explicit
nulls in flexible types.
This allows for interop between multiple files in cases where
```scala
class Unsafe_1 {
def foo(s: String): String = {
if (s == null) then "nullString"
else s
}
}
```
compiled without explicit nulls can still be used in
```scala
def Flexible_2() =
val s2: String | Null = "foo"
val unsafe = new Unsafe_1()
val s: String = unsafe.foo(s2)
unsafe.foo("")
unsafe.foo(null)
```
whereas the argument would have been a strictly non-null String, because
of the flexible type, the function call is now permitted.
Some explicit nulls neg tests have been excluded under the scala2
library tasty tests due to technical reasons, for example:
```scala
class S {
given Conversion[String, Array[String]] = _ => ???
def f = {
val s: String | Null = ???
val x: String = s // error
val xl = s.length // error
val xs: Array[String | Null] | Null = s // error
}
}
```
`val xl = s.length` will not give an error. This is because the .length
function is from the WrappedString.scala library. After desugaring, it
will become `wrapString(s).length`. Since the scala2 library is compiled
without explicit nulls, the types are flexified.`wrapString` will have
argument type FlexibleType(String) and return type FlexibleType(String),
therefore it will not give an error. Hence we need to exclude it from
the tasty tests.
[test_scala2_library_tasty]File tree
11 files changed
+277
-28
lines changed- compiler
- src/dotty/tools/dotc
- core
- classfile
- tasty
- typer
- test
- dotc
- dotty/tools
- dotc
- tests/explicit-nulls
- flexible-unpickle
- pos/interop-sam-src
11 files changed
+277
-28
lines changedLines changed: 35 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
38 | - | ||
38 | + | ||
39 | 39 |
| |
40 | 40 |
| |
41 | 41 |
| |
| |||
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
58 | - | ||
59 | 58 |
| |
60 | 59 |
| |
61 | - | ||
62 | - | ||
60 | + | ||
61 | + | ||
62 | + | ||
63 | 63 |
| |
64 | 64 |
| |
65 | 65 |
| |
| |||
80 | 80 |
| |
81 | 81 |
| |
82 | 82 |
| |
83 | - | ||
83 | + | ||
84 | 84 |
| |
85 | - | ||
85 | + | ||
86 | 86 |
| |
87 | - | ||
87 | + | ||
88 | 88 |
| |
89 | - | ||
90 | - | ||
89 | + | ||
90 | + | ||
91 | 91 |
| |
92 | 92 |
| |
93 | 93 |
| |
| |||
97 | 97 |
| |
98 | 98 |
| |
99 | 99 |
| |
100 | - | ||
100 | + | ||
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
107 | - | ||
107 | + | ||
108 | 108 |
| |
109 | - | ||
109 | + | ||
110 | 110 |
| |
111 | 111 |
| |
112 | 112 |
| |
113 | - | ||
114 | - | ||
115 | - | ||
116 | - | ||
117 | - | ||
118 | - | ||
119 | - | ||
113 | + | ||
114 | + | ||
115 | + | ||
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | ||
123 | + | ||
124 | + | ||
125 | + | ||
120 | 126 |
| |
121 | 127 |
| |
122 | 128 |
| |
| |||
130 | 136 |
| |
131 | 137 |
| |
132 | 138 |
| |
133 | - | ||
139 | + | ||
134 | 140 |
| |
135 | 141 |
| |
136 | 142 |
| |
| |||
140 | 146 |
| |
141 | 147 |
| |
142 | 148 |
| |
149 | + | ||
143 | 150 |
| |
144 | 151 |
| |
145 | 152 |
| |
| |||
149 | 156 |
| |
150 | 157 |
| |
151 | 158 |
| |
159 | + | ||
160 | + | ||
161 | + | ||
162 | + | ||
163 | + | ||
164 | + | ||
165 | + | ||
166 | + | ||
152 | 167 |
| |
153 | 168 |
| |
154 | 169 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1888 | 1888 |
| |
1889 | 1889 |
| |
1890 | 1890 |
| |
1891 | + | ||
1892 | + | ||
1891 | 1893 |
| |
1892 | 1894 |
| |
1893 | 1895 |
| |
| |||
3428 | 3430 |
| |
3429 | 3431 |
| |
3430 | 3432 |
| |
3431 | - | ||
3433 | + | ||
3432 | 3434 |
| |
3433 | 3435 |
| |
3434 | 3436 |
| |
3435 | 3437 |
| |
3436 | 3438 |
| |
3437 | 3439 |
| |
3438 | 3440 |
| |
3439 | - | ||
3441 | + | ||
3442 | + | ||
3443 | + | ||
3440 | 3444 |
| |
3441 | 3445 |
| |
3442 | 3446 |
| |
| |||
3456 | 3460 |
| |
3457 | 3461 |
| |
3458 | 3462 |
| |
3463 | + | ||
3464 | + | ||
3465 | + | ||
3466 | + | ||
3467 | + | ||
3468 | + | ||
3469 | + | ||
3470 | + | ||
3471 | + | ||
3459 | 3472 |
| |
3460 | 3473 |
| |
3461 | 3474 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
519 | 519 |
| |
520 | 520 |
| |
521 | 521 |
| |
522 | - | ||
522 | + | ||
523 | 523 |
| |
524 | 524 |
| |
525 | 525 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
921 | 921 |
| |
922 | 922 |
| |
923 | 923 |
| |
924 | + | ||
925 | + | ||
926 | + | ||
927 | + | ||
928 | + | ||
929 | + | ||
924 | 930 |
| |
925 | 931 |
| |
926 | 932 |
| |
| |||
937 | 943 |
| |
938 | 944 |
| |
939 | 945 |
| |
946 | + | ||
940 | 947 |
| |
941 | 948 |
| |
942 | 949 |
| |
943 | 950 |
| |
951 | + | ||
944 | 952 |
| |
945 | 953 |
| |
946 | 954 |
| |
| |||
978 | 986 |
| |
979 | 987 |
| |
980 | 988 |
| |
989 | + | ||
990 | + | ||
991 | + | ||
981 | 992 |
| |
982 | 993 |
| |
983 | 994 |
| |
| |||
986 | 997 |
| |
987 | 998 |
| |
988 | 999 |
| |
1000 | + | ||
989 | 1001 |
| |
990 | 1002 |
| |
991 | 1003 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1921 | 1921 |
| |
1922 | 1922 |
| |
1923 | 1923 |
| |
1924 | - | ||
1924 | + | ||
1925 | 1925 |
| |
1926 | 1926 |
| |
1927 | 1927 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | + | ||
2 | + | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | + | ||
7 | + | ||
8 | + | ||
9 | + | ||
10 | + | ||
11 | + | ||
12 | + | ||
13 | + | ||
14 | + | ||
15 | + | ||
16 | + | ||
17 | + |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
51 | + | ||
51 | 52 |
| |
52 | 53 |
| |
53 | 54 |
| |
54 | 55 |
| |
55 | 56 |
| |
56 | 57 |
| |
57 | 58 |
| |
59 | + | ||
60 | + | ||
61 | + | ||
58 | 62 |
| |
59 | 63 |
| |
60 | 64 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
208 | 208 |
| |
209 | 209 |
| |
210 | 210 |
| |
211 | - | ||
211 | + | ||
212 | 212 |
| |
213 | - | ||
213 | + | ||
214 | 214 |
| |
215 | 215 |
| |
216 | 216 |
| |
| |||
220 | 220 |
| |
221 | 221 |
| |
222 | 222 |
| |
223 | - | ||
224 | - | ||
223 | + | ||
224 | + | ||
225 | + | ||
226 | + | ||
227 | + | ||
228 | + | ||
229 | + | ||
230 | + | ||
231 | + | ||
232 | + | ||
233 | + | ||
234 | + | ||
225 | 235 |
| |
226 | 236 |
| |
227 | 237 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | + | ||
2 | + | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | + | ||
7 | + | ||
8 | + | ||
9 | + | ||
10 | + | ||
11 | + | ||
12 | + | ||
13 | + | ||
14 | + | ||
15 | + | ||
16 | + | ||
17 | + | ||
18 | + | ||
19 | + | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | + | ||
24 | + | ||
25 | + | ||
26 | + | ||
27 | + | ||
28 | + | ||
29 | + | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | + | ||
34 | + | ||
35 | + | ||
36 | + | ||
37 | + | ||
38 | + | ||
39 | + | ||
40 | + | ||
41 | + | ||
42 | + | ||
43 | + | ||
44 | + | ||
45 | + | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | + | ||
51 | + | ||
52 | + | ||
53 | + | ||
54 | + | ||
55 | + | ||
56 | + | ||
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | ||
61 | + | ||
62 | + | ||
63 | + | ||
64 | + | ||
65 | + | ||
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | ||
78 | + | ||
79 | + | ||
80 | + | ||
81 | + | ||
82 | + | ||
83 | + | ||
84 | + | ||
85 | + | ||
86 | + | ||
87 | + | ||
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | ||
92 | + | ||
93 | + | ||
94 | + | ||
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | ||
99 | + |
0 commit comments