Skip to content

Commit fd251d8

Browse files
committed
Revert "Do not nullify Modules"
This reverts commit d254401.
1 parent be54aa3 commit fd251d8

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

compiler/src/dotty/tools/dotc/core/JavaNullInterop.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ object JavaNullInterop {
5858
// assert(sym.is(JavaDefined), "can only nullify java-defined members")
5959

6060
// Some special cases when nullifying the type
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
61+
if isEnumValueDef || sym.name == nme.TYPE_ then
62+
// Don't nullify the `TYPE` field in every class and Java enum instances
6463
tp
6564
else if sym.name == nme.toString_ || sym.isConstructor || hasNotNullAnnot(sym) then
6665
// Don't nullify the return type of the `toString` method.

tests/explicit-nulls/flexible-unpickle/Flexible_2.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import unsafeNulls.Foo.*
2-
import unsafeNulls.Unsafe_1
3-
41
@main
52
def Flexible_2() =
63
val s2: String | Null = "foo"
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
package unsafeNulls
2-
31
class Unsafe_1 {
42
def foo(s: String): String = {
53
if (s == null) then "nullString"
64
else s
75
}
86
}
9-
10-
object Foo {
11-
def bar = "bar!"
12-
}

0 commit comments

Comments
 (0)