summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-12-30 18:31:41 -0800
committerEugene Burmako <xeno.by@gmail.com>2012-12-30 18:31:41 -0800
commit2b3c6606a637746c14785f4de0829d9a9598e899 (patch)
tree9ba95786cac5be5e92cdce667eb69c50e1327027
parent93f3d63d67b0b1e81322b67488b80ee0a34d74e6 (diff)
parent2015ad3ebd833225e93ed19604760a6da2522bb1 (diff)
downloadscala-2b3c6606a637746c14785f4de0829d9a9598e899.tar.gz
scala-2b3c6606a637746c14785f4de0829d9a9598e899.tar.bz2
scala-2b3c6606a637746c14785f4de0829d9a9598e899.zip
Merge pull request #1807 from scalamacros/topic/ident-deprecation-warnings
the scanner is now less eager about deprecations
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala11
-rw-r--r--test/files/neg/macro-false-deprecation-warning.check4
-rw-r--r--test/files/neg/macro-false-deprecation-warning.flags1
-rw-r--r--test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala15
4 files changed, 30 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index af7f48988f..3025e4c440 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -104,6 +104,11 @@ trait Scanners extends ScannersCommon {
cbuf.append(c)
}
+ /** Determines whether this scanner should emit identifier deprecation warnings,
+ * e.g. when seeing `macro` or `then`, which are planned to become keywords in future versions of Scala.
+ */
+ protected def emitIdentifierDeprecationWarnings = true
+
/** Clear buffer and set name and token */
private def finishNamed(idtoken: Int = IDENTIFIER) {
name = newTermName(cbuf.toString)
@@ -113,7 +118,7 @@ trait Scanners extends ScannersCommon {
val idx = name.start - kwOffset
if (idx >= 0 && idx < kwArray.length) {
token = kwArray(idx)
- if (token == IDENTIFIER && allowIdent != name)
+ if (token == IDENTIFIER && allowIdent != name && emitIdentifierDeprecationWarnings)
deprecationWarning(name+" is now a reserved word; usage as an identifier is deprecated")
}
}
@@ -1461,6 +1466,10 @@ trait Scanners extends ScannersCommon {
delete(bracePairs)
}
+ // don't emit deprecation warnings about identifiers like `macro` or `then`
+ // when skimming through the source file trying to heal braces
+ override def emitIdentifierDeprecationWarnings = false
+
override def error(offset: Int, msg: String) {}
}
}
diff --git a/test/files/neg/macro-false-deprecation-warning.check b/test/files/neg/macro-false-deprecation-warning.check
new file mode 100644
index 0000000000..7d56505ec4
--- /dev/null
+++ b/test/files/neg/macro-false-deprecation-warning.check
@@ -0,0 +1,4 @@
+Impls_Macros_1.scala:5: error: illegal start of simple expression
+}
+^
+one error found
diff --git a/test/files/neg/macro-false-deprecation-warning.flags b/test/files/neg/macro-false-deprecation-warning.flags
new file mode 100644
index 0000000000..59af162db6
--- /dev/null
+++ b/test/files/neg/macro-false-deprecation-warning.flags
@@ -0,0 +1 @@
+-language:experimental.macros -deprecation \ No newline at end of file
diff --git a/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala b/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala
new file mode 100644
index 0000000000..6dc2ea114b
--- /dev/null
+++ b/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala
@@ -0,0 +1,15 @@
+import scala.reflect.macros.Context
+
+object Helper {
+ def unapplySeq[T](x: List[T]): Option[Seq[T]] =
+}
+
+object Macros {
+ def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = {
+ c.universe.reify(Helper.unapplySeq(x.splice))
+ }
+
+ object UnapplyMacro {
+ def unapplySeq[T](x: List[T]): Option[Seq[T]] = macro impl[T]
+ }
+}