From cc764e944817628cbca3f7b5a195cdb495ca8f38 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 13 Apr 2012 12:40:59 -0700 Subject: Added languageFeature annotation (was missing before). Resolved problem with late loading of nested classes in Definitions. Resolved handling of deprecated idents `then` and `macro`. Massaged test flags. --- .../scala/tools/nsc/ast/parser/Parsers.scala | 75 +++------------------- 1 file changed, 10 insertions(+), 65 deletions(-) (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala') diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index ef11427677..65225b185b 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1773,21 +1773,7 @@ self => */ def pattern2(): Tree = { val nameOffset = in.offset - def warnIfMacro(tree: Tree): Unit = { - def check(name: Name): Unit = if (name.toString == nme.MACROkw.toString) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") - tree match { - case _: BackQuotedIdent => - ; - case Ident(name) => - check(name) - case _ => - ; - } - } - val p = pattern3() - warnIfMacro(p) if (in.token != AT) p else p match { @@ -2463,8 +2449,6 @@ self => val nameOffset = in.offset val isBackquoted = in.token == BACKQUOTED_IDENT val name = ident() - if (name.toString == nme.MACROkw.toString && !isBackquoted) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") funDefRest(start, nameOffset, mods, name) } } @@ -2480,7 +2464,7 @@ self => val vparamss = paramClauses(name, contextBoundBuf.toList, false) newLineOptWhenFollowedBy(LBRACE) var restype = fromWithinReturnType(typedOpt()) - val rhs = + val rhs = if (isStatSep || in.token == RBRACE) { if (restype.isEmpty) restype = scalaUnitConstr newmods |= Flags.DEFERRED @@ -2489,11 +2473,15 @@ self => restype = scalaUnitConstr blockExpr() } else { - accept(EQUALS) - if (settings.Xmacros.value && in.token == MACRO || // [Martin] Xmacros can be retired now - in.token == IDENTIFIER && in.name == nme.MACROkw) { - in.nextToken() - newmods |= Flags.MACRO + if (in.token == EQUALS) { + in.nextTokenAllow(nme.MACROkw) + if (settings.Xmacros.value && in.token == MACRO || // [Martin] Xmacros can be retired now + in.token == IDENTIFIER && in.name == nme.MACROkw) { + in.nextToken() + newmods |= Flags.MACRO + } + } else { + accept(EQUALS) } expr() } @@ -2556,8 +2544,6 @@ self => val nameOffset = in.offset val isBackquoted = in.token == BACKQUOTED_IDENT val name = identForType() - if (name.toString == nme.MACROkw.toString && !isBackquoted) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") // @M! a type alias as well as an abstract type may declare type parameters val tparams = typeParamClauseOpt(name, null) in.token match { @@ -2617,9 +2603,6 @@ self => val nameOffset = in.offset val isBackquoted = in.token == BACKQUOTED_IDENT val name = identForType() - if (name.toString == nme.MACROkw.toString && !isBackquoted) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") - atPos(start, if (name == tpnme.ERROR) start else nameOffset) { savingClassContextBounds { val contextBoundBuf = new ListBuffer[Tree] @@ -2661,8 +2644,6 @@ self => val nameOffset = in.offset val isBackquoted = in.token == BACKQUOTED_IDENT val name = ident() - if (name.toString == nme.MACROkw.toString && !isBackquoted) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") val tstart = in.offset atPos(start, if (name == nme.ERROR) start else nameOffset) { val mods1 = if (in.token == SUBTYPE) mods | Flags.DEFERRED else mods @@ -2841,24 +2822,7 @@ self => */ def packaging(start: Int): Tree = { val nameOffset = in.offset - def warnIfMacro(tree: Tree): Unit = { - def check(name: Name): Unit = if (name.toString == nme.MACROkw.toString) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") - tree match { - case _: BackQuotedIdent => - ; - case Ident(name) => - check(name) - case Select(qual, name) => - warnIfMacro(qual) - check(name) - case _ => - ; - } - } - val pkg = pkgQualId() - warnIfMacro(pkg) val stats = inBracesOrNil(topStatSeq()) makePackaging(start, pkg, stats) } @@ -3061,27 +3025,8 @@ self => } } else { val nameOffset = in.offset - def warnIfMacro(tree: Tree): Unit = { - def check(name: Name): Unit = if (name.toString == nme.MACROkw.toString) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") - tree match { - // [Eugene] pkgQualId never returns BackQuotedIdents - // this means that we'll get spurious warnings even if we wrap macro package name in backquotes - case _: BackQuotedIdent => - ; - case Ident(name) => - check(name) - case Select(qual, name) => - warnIfMacro(qual) - check(name) - case _ => - ; - } - } - in.flushDoc val pkg = pkgQualId() - warnIfMacro(pkg) if (in.token == EOF) { ts += makePackaging(start, pkg, List()) -- cgit v1.2.3