aboutsummaryrefslogtreecommitdiff
path: root/compiler/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-12-04 12:44:08 +0100
committerMartin Odersky <odersky@gmail.com>2016-12-17 18:34:27 +0100
commit63ba924a5ad9c01768be22f0b115c9501aa9f23a (patch)
tree2ed16fab59d9012882219d986178cff9735b6a03 /compiler/src
parente6da2137f48ca6019b826be501ac64e452e5fe7e (diff)
downloaddotty-63ba924a5ad9c01768be22f0b115c9501aa9f23a.tar.gz
dotty-63ba924a5ad9c01768be22f0b115c9501aa9f23a.tar.bz2
dotty-63ba924a5ad9c01768be22f0b115c9501aa9f23a.zip
Cleanup of implicit modifiers scheme
Implicit modifiers were quite irregular compared to the other ones. This commit does a cleanup.
Diffstat (limited to 'compiler/src')
-rw-r--r--compiler/src/dotty/tools/dotc/ast/untpd.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/core/Comments.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/parsing/Parsers.scala25
3 files changed, 14 insertions, 15 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala
index 25b69b1f5..9707770d5 100644
--- a/compiler/src/dotty/tools/dotc/ast/untpd.scala
+++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala
@@ -115,7 +115,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
case class Var() extends Mod(Flags.Mutable)
- case class Implicit(flag: FlagSet = Flags.ImplicitCommon) extends Mod(flag)
+ case class Implicit() extends Mod(Flags.ImplicitCommon)
case class Final() extends Mod(Flags.Final)
diff --git a/compiler/src/dotty/tools/dotc/core/Comments.scala b/compiler/src/dotty/tools/dotc/core/Comments.scala
index 1e623db4d..2559209c3 100644
--- a/compiler/src/dotty/tools/dotc/core/Comments.scala
+++ b/compiler/src/dotty/tools/dotc/core/Comments.scala
@@ -119,7 +119,7 @@ object Comments {
def apply(comment: Comment, code: String, codePos: Position)(implicit ctx: Context) =
new UseCase(comment, code, codePos) {
val untpdCode = {
- val tree = new Parser(new SourceFile("<usecase>", code)).localDef(codePos.start, EmptyFlags)
+ val tree = new Parser(new SourceFile("<usecase>", code)).localDef(codePos.start)
tree match {
case tree: untpd.DefDef =>
diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
index dabd8d2b0..5dd0df022 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -1067,7 +1067,7 @@ object Parsers {
case FOR =>
forExpr()
case IMPLICIT =>
- implicitClosure(in.skipToken(), location)
+ implicitClosure(in.offset, location, atPos(in.skipToken()) { Mod.Implicit() })
case _ =>
expr1Rest(postfixExpr(), location)
}
@@ -1118,9 +1118,8 @@ object Parsers {
/** Expr ::= implicit Id `=>' Expr
* BlockResult ::= implicit Id [`:' InfixType] `=>' Block
*/
- def implicitClosure(start: Int, location: Location.Value, implicitMod: Option[Mod] = None): Tree = {
- var mods = atPos(start) { Modifiers(Implicit) }
- if (implicitMod.nonEmpty) mods = mods.withAddedMod(implicitMod.get)
+ def implicitClosure(start: Int, location: Location.Value, implicitMod: Mod): Tree = {
+ val mods = Modifiers(Implicit).withAddedMod(implicitMod)
val id = termIdent()
val paramExpr =
if (location == Location.InBlock && in.token == COLON)
@@ -1489,7 +1488,7 @@ object Parsers {
private def modOfToken(tok: Int): Mod = tok match {
case ABSTRACT => Mod.Abstract()
case FINAL => Mod.Final()
- case IMPLICIT => Mod.Implicit(ImplicitCommon)
+ case IMPLICIT => Mod.Implicit()
case INLINE => Mod.Inline()
case LAZY => Mod.Lazy()
case OVERRIDE => Mod.Override()
@@ -1745,7 +1744,7 @@ object Parsers {
else {
if (in.token == IMPLICIT) {
implicitOffset = in.offset
- implicitMod = atPos(in.skipToken()) { Mod.Implicit(Implicit) }
+ implicitMod = atPos(in.skipToken()) { Mod.Implicit() }
}
commaSeparated(param)
}
@@ -2218,9 +2217,9 @@ object Parsers {
stats.toList
}
- def localDef(start: Int, implicitFlag: FlagSet, implicitMod: Option[Mod] = None): Tree = {
- var mods = addFlag(defAnnotsMods(localModifierTokens), implicitFlag)
- if (implicitMod.nonEmpty) mods = mods.withAddedMod(implicitMod.get)
+ def localDef(start: Int, implicitMod: Option[Mod] = None): Tree = {
+ var mods = defAnnotsMods(localModifierTokens)
+ for (imod <- implicitMod) mods = (mods | ImplicitCommon).withAddedMod(imod)
defOrDcl(start, mods)
}
@@ -2243,11 +2242,11 @@ object Parsers {
else if (isDefIntro(localModifierTokens))
if (in.token == IMPLICIT) {
val start = in.offset
- val mod = atPos(in.skipToken()) { Mod.Implicit(ImplicitCommon) }
- if (isIdent) stats += implicitClosure(start, Location.InBlock, Some(mod))
- else stats += localDef(start, ImplicitCommon, Some(mod))
+ val mod = atPos(in.skipToken()) { Mod.Implicit() }
+ if (isIdent) stats += implicitClosure(start, Location.InBlock, mod)
+ else stats += localDef(start, Some(mod))
} else {
- stats += localDef(in.offset, EmptyFlags)
+ stats += localDef(in.offset)
}
else if (!isStatSep && (in.token != CASE)) {
exitOnError = mustStartStat