File tree 3 files changed +12
-2
lines changed
compiler/src/dotty/tools/dotc/core
tests/explicit-nulls/flexible-unpickle
3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -58,8 +58,9 @@ object JavaNullInterop {
58
58
// assert(sym.is(JavaDefined), "can only nullify java-defined members")
59
59
60
60
// Some special cases when nullifying the type
61
- if isEnumValueDef || sym.name == nme.TYPE_ then
62
- // Don't nullify the `TYPE` field in every class and Java enum instances
61
+ if isEnumValueDef || sym.name == nme.TYPE_ // Don't nullify the `TYPE` field in every class and Java enum instances
62
+ || sym.is(Flags .ModuleVal ) // Don't nullify Modules
63
+ then
63
64
tp
64
65
else if sym.name == nme.toString_ || sym.isConstructor || hasNotNullAnnot(sym) then
65
66
// Don't nullify the return type of the `toString` method.
Original file line number Diff line number Diff line change
1
+ import unsafeNulls .Foo .*
2
+ import unsafeNulls .Unsafe_1
3
+
1
4
@ main
2
5
def Flexible_2 () =
3
6
val s2 : String | Null = " foo"
Original file line number Diff line number Diff line change
1
+ package unsafeNulls
2
+
1
3
class Unsafe_1 {
2
4
def foo (s : String ): String = {
3
5
if (s == null ) then " nullString"
4
6
else s
5
7
}
6
8
}
9
+
10
+ object Foo {
11
+ def bar = " bar!"
12
+ }
You can’t perform that action at this time.
0 commit comments