From 4b76eeaa13176aede421af3fe86c392c438b0e5d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 2 Nov 2015 22:24:54 +0100 Subject: Add scalaMode and testScalaMode to TypeOps --- src/dotty/tools/dotc/core/TypeOps.scala | 10 ++++++++++ src/dotty/tools/dotc/parsing/Parsers.scala | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') 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) -- cgit v1.2.3