diff options
Diffstat (limited to 'src/compiler')
4 files changed, 13 insertions, 8 deletions
diff --git a/src/compiler/scala/reflect/internal/settings/MutableSettings.scala b/src/compiler/scala/reflect/internal/settings/MutableSettings.scala index 45ba4ed3e6..8640a23aa7 100644 --- a/src/compiler/scala/reflect/internal/settings/MutableSettings.scala +++ b/src/compiler/scala/reflect/internal/settings/MutableSettings.scala @@ -44,4 +44,5 @@ abstract class MutableSettings extends AbsSettings { def maxClassfileName: IntSetting def Xexperimental: BooleanSetting def XoldPatmat: BooleanSetting + def XnoPatmatAnalysis: BooleanSetting }
\ No newline at end of file diff --git a/src/compiler/scala/reflect/runtime/Settings.scala b/src/compiler/scala/reflect/runtime/Settings.scala index bbe4d60e9c..b247797c6c 100644 --- a/src/compiler/scala/reflect/runtime/Settings.scala +++ b/src/compiler/scala/reflect/runtime/Settings.scala @@ -35,4 +35,5 @@ class Settings extends internal.settings.MutableSettings { val Xexperimental = new BooleanSetting(false) val deepCloning = new BooleanSetting (false) val XoldPatmat = new BooleanSetting(false) + val XnoPatmatAnalysis = new BooleanSetting(false) } diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index efde2cee25..88a89d54eb 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -109,6 +109,7 @@ trait ScalaSettings extends AbsScalaSettings val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "") val XoldPatmat = BooleanSetting ("-Xoldpatmat", "Use the pre-2.10 pattern matcher. Otherwise, the 'virtualizing' pattern matcher is used in 2.10.") + val XnoPatmatAnalysis = BooleanSetting ("-Xno-patmat-analysis", "Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.") /** Compatibility stubs for options whose value name did * not previously match the option name. diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index 5f8ae240cc..3b2c4d06c4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -1115,14 +1115,16 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL def isSwitchAnnotation(tpe: Type) = tpe hasAnnotation SwitchClass def isUncheckedAnnotation(tpe: Type) = tpe hasAnnotation UncheckedClass - val (unchecked, requireSwitch) = scrut match { - case Typed(_, tpt) => - (isUncheckedAnnotation(tpt.tpe), - // matches with two or fewer cases need not apply for switchiness (if-then-else will do) - isSwitchAnnotation(tpt.tpe) && casesNoSubstOnly.lengthCompare(2) > 0) - case _ => - (false, false) - } + val (unchecked, requireSwitch) = + if (settings.XnoPatmatAnalysis.value) (true, false) + else scrut match { + case Typed(_, tpt) => + (isUncheckedAnnotation(tpt.tpe), + // matches with two or fewer cases need not apply for switchiness (if-then-else will do) + isSwitchAnnotation(tpt.tpe) && casesNoSubstOnly.lengthCompare(2) > 0) + case _ => + (false, false) + } emitSwitch(scrut, scrutSym, casesNoSubstOnly, pt, matchFailGenOverride).getOrElse{ if (requireSwitch) typer.context.unit.warning(scrut.pos, "could not emit switch for @switch annotated match") |