From d296dd4cd5b7072d9b53a46d338bc9d68ee23300 Mon Sep 17 00:00:00 2001 From: noti0na1 Date: Mon, 31 Jan 2022 13:26:43 -0500 Subject: [PATCH] Remove StickyKey --- .../src/dotty/tools/dotc/transform/PatternMatcher.scala | 7 +------ compiler/src/dotty/tools/dotc/typer/Nullables.scala | 7 ------- compiler/src/dotty/tools/dotc/typer/Typer.scala | 5 +---- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala index fb4657f9d01a..5ba43253e8b3 100644 --- a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -13,7 +13,6 @@ import SymUtils._ import Flags._, Constants._ import Decorators._ import NameKinds.{PatMatStdBinderName, PatMatAltsName, PatMatResultName} -import typer.Nullables import config.Printers.patmatch import reporting._ import dotty.tools.dotc.ast._ @@ -44,12 +43,8 @@ class PatternMatcher extends MiniPhase { case rt => tree.tpe val translated = new Translator(matchType, this).translateMatch(tree) - val engineCtx = - if tree.hasAttachment(Nullables.UnsafeNullsMatch) - then ctx.retractMode(Mode.SafeNulls) else ctx - // check exhaustivity and unreachability - val engine = new patmat.SpaceEngine()(using engineCtx) + val engine = new patmat.SpaceEngine engine.checkExhaustivity(tree) engine.checkRedundancy(tree) diff --git a/compiler/src/dotty/tools/dotc/typer/Nullables.scala b/compiler/src/dotty/tools/dotc/typer/Nullables.scala index dc3957e78510..0ea7207c7b2b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Nullables.scala +++ b/compiler/src/dotty/tools/dotc/typer/Nullables.scala @@ -20,13 +20,6 @@ import ast.Trees.mods object Nullables: import ast.tpd._ - /** An attachment that represents a match tree is created under Unsafe Nulls. - * This is used to pass Unsafe Nulls information to PatternMatcher Phase, - * so we don't get Match case Unreachable Warning when using `case null => ???` - * on non-nullable type. - */ - val UnsafeNullsMatch = Property.StickyKey[Unit] - inline def unsafeNullsEnabled(using Context): Boolean = ctx.explicitNulls && !ctx.mode.is(Mode.SafeNulls) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 112a5dd7fd18..02f3f6b4f164 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1499,7 +1499,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer } def typedMatch(tree: untpd.Match, pt: Type)(using Context): Tree = - val tree1 = tree.selector match { + tree.selector match { case EmptyTree => if (tree.isInline) { checkInInlineContext("summonFrom", tree.srcPos) @@ -1601,9 +1601,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer result } } - if Nullables.unsafeNullsEnabled && ctx.phase == Phases.typerPhase then - tree1.putAttachment(Nullables.UnsafeNullsMatch, ()) - tree1 /** Special typing of Match tree when the expected type is a MatchType, * and the patterns of the Match tree and the MatchType correspond.