diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 8e59397189ae..49022cd4cdb4 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -323,12 +323,6 @@ class SpaceEngine(using Context) extends SpaceLogic { private val constantNullType = ConstantType(Constant(null)) - /** Does the given tree stand for the literal `null`? */ - def isNullLit(tree: Tree): Boolean = tree match { - case Literal(Constant(null)) => true - case _ => false - } - override def intersectUnrelatedAtomicTypes(tp1: Type, tp2: Type): Space = trace(s"atomic intersection: ${AndType(tp1, tp2).show}", debug) { // Precondition: !isSubType(tp1, tp2) && !isSubType(tp2, tp1). if !ctx.mode.is(Mode.SafeNulls) && (tp1.isNullType || tp2.isNullType) then diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 7bf1d1298a5b..4fb5740b2c53 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1581,7 +1581,7 @@ class Typer extends Namer result } } - if Nullables.unsafeNullsEnabled then + if Nullables.unsafeNullsEnabled && ctx.phase == Phases.typerPhase then tree1.putAttachment(Nullables.UnsafeNullsMatch, ()) tree1 diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 4a85d863ed9f..78f99d3b8660 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -322,6 +322,7 @@ class CompilationTests { aggregateTests( compileFilesInDir("tests/explicit-nulls/pos", explicitNullsOptions), compileFilesInDir("tests/explicit-nulls/pos-separate", explicitNullsOptions), + compileFilesInDir("tests/explicit-nulls/pos-patmat", explicitNullsOptions and "-Xfatal-warnings"), compileFilesInDir("tests/explicit-nulls/unsafe-common", explicitNullsOptions and "-language:unsafeNulls"), ) }.checkCompile() diff --git a/tests/explicit-nulls/neg-patmat/unsafe-match-null-pat.scala b/tests/explicit-nulls/pos-patmat/unsafe-match-null-pat.scala similarity index 100% rename from tests/explicit-nulls/neg-patmat/unsafe-match-null-pat.scala rename to tests/explicit-nulls/pos-patmat/unsafe-match-null-pat.scala