Skip to content

Commit d296dd4

Browse files
committed
Remove StickyKey
1 parent 37dcada commit d296dd4

File tree

3 files changed

+2
-17
lines changed

3 files changed

+2
-17
lines changed

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import SymUtils._
1313
import Flags._, Constants._
1414
import Decorators._
1515
import NameKinds.{PatMatStdBinderName, PatMatAltsName, PatMatResultName}
16-
import typer.Nullables
1716
import config.Printers.patmatch
1817
import reporting._
1918
import dotty.tools.dotc.ast._
@@ -44,12 +43,8 @@ class PatternMatcher extends MiniPhase {
4443
case rt => tree.tpe
4544
val translated = new Translator(matchType, this).translateMatch(tree)
4645

47-
val engineCtx =
48-
if tree.hasAttachment(Nullables.UnsafeNullsMatch)
49-
then ctx.retractMode(Mode.SafeNulls) else ctx
50-
5146
// check exhaustivity and unreachability
52-
val engine = new patmat.SpaceEngine()(using engineCtx)
47+
val engine = new patmat.SpaceEngine
5348
engine.checkExhaustivity(tree)
5449
engine.checkRedundancy(tree)
5550

compiler/src/dotty/tools/dotc/typer/Nullables.scala

-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ import ast.Trees.mods
2020
object Nullables:
2121
import ast.tpd._
2222

23-
/** An attachment that represents a match tree is created under Unsafe Nulls.
24-
* This is used to pass Unsafe Nulls information to PatternMatcher Phase,
25-
* so we don't get Match case Unreachable Warning when using `case null => ???`
26-
* on non-nullable type.
27-
*/
28-
val UnsafeNullsMatch = Property.StickyKey[Unit]
29-
3023
inline def unsafeNullsEnabled(using Context): Boolean =
3124
ctx.explicitNulls && !ctx.mode.is(Mode.SafeNulls)
3225

compiler/src/dotty/tools/dotc/typer/Typer.scala

+1-4
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
14991499
}
15001500

15011501
def typedMatch(tree: untpd.Match, pt: Type)(using Context): Tree =
1502-
val tree1 = tree.selector match {
1502+
tree.selector match {
15031503
case EmptyTree =>
15041504
if (tree.isInline) {
15051505
checkInInlineContext("summonFrom", tree.srcPos)
@@ -1601,9 +1601,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
16011601
result
16021602
}
16031603
}
1604-
if Nullables.unsafeNullsEnabled && ctx.phase == Phases.typerPhase then
1605-
tree1.putAttachment(Nullables.UnsafeNullsMatch, ())
1606-
tree1
16071604

16081605
/** Special typing of Match tree when the expected type is a MatchType,
16091606
* and the patterns of the Match tree and the MatchType correspond.

0 commit comments

Comments
 (0)