Skip to content

Commit

Permalink
Remove StickyKey
Browse files Browse the repository at this point in the history
  • Loading branch information
noti0na1 committed Jan 31, 2022
1 parent 37dcada commit d296dd4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
7 changes: 1 addition & 6 deletions compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down Expand Up @@ -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)

Expand Down
7 changes: 0 additions & 7 deletions compiler/src/dotty/tools/dotc/typer/Nullables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d296dd4

Please sign in to comment.