summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-05-11 13:02:53 -0700
committerPaul Phillips <paulp@improving.org>2013-05-11 13:02:53 -0700
commit751daa9b3825543bd04eaa4eab6438f8410f6040 (patch)
tree46d83d8adc9a5916c65a9ae1ca6ab173a2a80d6a /src/compiler/scala/tools/nsc/typechecker/Contexts.scala
parent1850ddf380789e364813111282af5ff11e65b52c (diff)
downloadscala-751daa9b3825543bd04eaa4eab6438f8410f6040.tar.gz
scala-751daa9b3825543bd04eaa4eab6438f8410f6040.tar.bz2
scala-751daa9b3825543bd04eaa4eab6438f8410f6040.zip
Started eliminating modes.
Consolidating the scattered typer state in Context, where it's relatively easy to keep an eye on, rather than threaded throughout the typer in sneaky/sticky bitmasks. The general pattern will be what was once an explicitly passed around bit in Mode becomes an implicitly propagated-as-appropriate bit in Context. In this commit: ALTmode becomes context mode "PatternAlternative" STARmode becomes context mode "StarPatterns" SUPERCONSTRmode becomes context mode "SuperInit"
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index e3bb595bd7..0633c1485f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -219,8 +219,14 @@ trait Contexts { self: Analyzer =>
var namedApplyBlockInfo: Option[(Tree, NamedApplyInfo)] = None
var prefix: Type = NoPrefix
+ def inSuperInit_=(value: Boolean) = this(SuperInit) = value
+ def inSuperInit = this(SuperInit)
def inConstructorSuffix_=(value: Boolean) = this(ConstructorSuffix) = value
def inConstructorSuffix = this(ConstructorSuffix)
+ def inPatAlternative_=(value: Boolean) = this(PatternAlternative) = value
+ def inPatAlternative = this(PatternAlternative)
+ def starPatterns_=(value: Boolean) = this(StarPatterns) = value
+ def starPatterns = this(StarPatterns)
def returnsSeen_=(value: Boolean) = this(ReturnsSeen) = value
def returnsSeen = this(ReturnsSeen)
def inSelfSuperCall_=(value: Boolean) = this(SelfSuperCall) = value
@@ -349,6 +355,8 @@ trait Contexts { self: Analyzer =>
def withImplicitsDisabledAllowEnrichment[T](op: => T): T = withMode(enabled = EnrichmentEnabled, disabled = ImplicitsEnabled)(op)
def withMacrosEnabled[T](op: => T): T = withMode(enabled = MacrosEnabled)(op)
def withMacrosDisabled[T](op: => T): T = withMode(disabled = MacrosEnabled)(op)
+ def withStarPatterns[T](op: => T): T = withMode(enabled = StarPatterns)(op)
+ def withSuperInit[T](op: => T): T = withMode(enabled = SuperInit)(op)
/** @return true if the `expr` evaluates to true within a silent Context that incurs no errors */
@inline final def inSilentMode(expr: => Boolean): Boolean = {
@@ -1329,18 +1337,29 @@ object ContextMode {
// TODO This seems to directly overlap with Mode.SNDTRYmode
final val ReTyping: ContextMode = 1 << 10
+ /** Are we typechecking pattern alternatives. Formerly ALTmode. */
+ final val PatternAlternative: ContextMode = 1 << 11
+
+ /** Are star patterns allowed. Formerly STARmode. */
+ final val StarPatterns: ContextMode = 1 << 12
+
+ /** Are we typing the "super" in a superclass constructor call super.<init>. Formerly SUPERCONSTRmode. */
+ final val SuperInit: ContextMode = 1 << 13
+
final val DefaultMode: ContextMode = MacrosEnabled
private val contextModeNameMap = Map(
- ReportErrors -> "ReportErrors",
- BufferErrors -> "BufferErrors",
- AmbiguousErrors -> "AmbiguousErrors",
- ConstructorSuffix -> "ConstructorSuffix",
- SelfSuperCall -> "SelfSuperCall",
- ImplicitsEnabled -> "ImplicitsEnabled",
- MacrosEnabled -> "MacrosEnabled",
- Checking -> "Checking",
- ReTyping -> "ReTyping"
+ ReportErrors -> "ReportErrors",
+ BufferErrors -> "BufferErrors",
+ AmbiguousErrors -> "AmbiguousErrors",
+ ConstructorSuffix -> "ConstructorSuffix",
+ SelfSuperCall -> "SelfSuperCall",
+ ImplicitsEnabled -> "ImplicitsEnabled",
+ MacrosEnabled -> "MacrosEnabled",
+ Checking -> "Checking",
+ ReTyping -> "ReTyping",
+ PatternAlternative -> "PatternAlternative",
+ StarPatterns -> "StarPatterns"
)
}