aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-11-02 22:24:54 +0100
committerMartin Odersky <odersky@gmail.com>2015-11-05 13:57:37 +0100
commit4b76eeaa13176aede421af3fe86c392c438b0e5d (patch)
treeca75631b01e9b803af50302d6eb39f688e308a76
parent4850629d244156d96a2a1bad231cddc0084d0d31 (diff)
downloaddotty-4b76eeaa13176aede421af3fe86c392c438b0e5d.tar.gz
dotty-4b76eeaa13176aede421af3fe86c392c438b0e5d.tar.bz2
dotty-4b76eeaa13176aede421af3fe86c392c438b0e5d.zip
Add scalaMode and testScalaMode to TypeOps
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala10
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala4
2 files changed, 12 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 77c6805f0..aa643256c 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -5,6 +5,7 @@ package core
import Contexts._, Types._, Symbols._, Names._, Flags._, Scopes._
import SymDenotations._, Denotations.Denotation
import config.Printers._
+import util.Positions._
import Decorators._
import StdNames._
import util.SimpleMap
@@ -572,6 +573,15 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
/** Is auto-tupling enabled? */
def canAutoTuple =
!featureEnabled(defn.LanguageModuleClass, nme.noAutoTupling)
+
+ def scala2Mode =
+ featureEnabled(defn.LanguageModuleClass, nme.Scala2)
+
+ def testScala2Mode(msg: String, pos: Position) = {
+ if (scala2Mode) migrationWarning(msg, pos)
+ scala2Mode
+ }
+
}
object TypeOps {
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index 8d230d321..e5202b515 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -259,7 +259,7 @@ object Parsers {
}
/** Cannot use ctx.featureEnabled because accessing the context would force too much */
- private def scala2mode(msg: => String, pos: Position = Position(in.offset)) = {
+ private def testScala2Mode(msg: String, pos: Position = Position(in.offset)) = {
val s2 = ctx.settings.language.value.contains(nme.Scala2.toString)
if (s2) ctx.migrationWarning(msg, source atPos pos)
s2
@@ -1731,7 +1731,7 @@ object Parsers {
*/
def defDefOrDcl(mods: Modifiers): Tree = atPos(tokenRange) {
def scala2ProcedureSyntax =
- scala2mode("Procedure syntax no longer supported; `=' should be inserted here")
+ testScala2Mode("Procedure syntax no longer supported; `=' should be inserted here")
if (in.token == THIS) {
in.nextToken()
val vparamss = paramClauses(nme.CONSTRUCTOR)