diff options
author | Paul Phillips <paulp@improving.org> | 2014-03-12 10:54:51 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2014-03-12 11:25:51 -0700 |
commit | 80fc8b7818205634caa3996b18b2fd156e9aabd8 (patch) | |
tree | c192604820fcb46886645ece9ca8e4b4c5496dc1 /src | |
parent | 9c38e86a5526887f93a3f031b19a0e4fa31745d3 (diff) | |
download | scala-80fc8b7818205634caa3996b18b2fd156e9aabd8.tar.gz scala-80fc8b7818205634caa3996b18b2fd156e9aabd8.tar.bz2 scala-80fc8b7818205634caa3996b18b2fd156e9aabd8.zip |
SI-8265 Restore 2.10 variance behavior under -Xsource:2.10
Issue deprecation warning under -Xsource:2.10 so time
travelers can have an authentic deprecation experience before
finding that their unsound code no longer compiles in 2.11.
The relevant ticket to the soundness issue is SI-6566.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 5 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/SymbolTable.scala | 1 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Variances.scala | 9 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index c5d0c8506a..35eab94333 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -236,6 +236,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) override def inform(msg: String) = inform(NoPosition, msg) override def globalError(msg: String) = globalError(NoPosition, msg) override def warning(msg: String) = warning(NoPosition, msg) + override def deprecationWarning(pos: Position, msg: String) = currentUnit.deprecationWarning(pos, msg) def globalError(pos: Position, msg: String) = reporter.error(pos, msg) def warning(pos: Position, msg: String) = if (settings.fatalWarnings) globalError(pos, msg) else reporter.warning(pos, msg) @@ -1236,7 +1237,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) } private val unitbuf = new SyncedCompilationBuffer - + val compiledFiles = new mutable.HashSet[String] /** A map from compiled top-level symbols to their source files */ @@ -1491,7 +1492,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) made to the underlying structure. */ def units: Iterator[CompilationUnit] = unitbuf.iterator - + def registerPickle(sym: Symbol): Unit = () /** does this run compile given class, module, or case factory? */ diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala index e50c65c9ca..c76dedbff4 100644 --- a/src/reflect/scala/reflect/internal/SymbolTable.scala +++ b/src/reflect/scala/reflect/internal/SymbolTable.scala @@ -51,6 +51,7 @@ abstract class SymbolTable extends macros.Universe val gen = new InternalTreeGen { val global: SymbolTable.this.type = SymbolTable.this } def log(msg: => AnyRef): Unit + def deprecationWarning(pos: Position, msg: String): Unit = warning(msg) def warning(msg: String): Unit = Console.err.println(msg) def inform(msg: String): Unit = Console.err.println(msg) def globalError(msg: String): Unit = abort(msg) diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala index 3bcfed7d34..cfe2ad8b87 100644 --- a/src/reflect/scala/reflect/internal/Variances.scala +++ b/src/reflect/scala/reflect/internal/Variances.scala @@ -75,7 +75,14 @@ trait Variances { def nextVariance(sym: Symbol, v: Variance): Variance = ( if (shouldFlip(sym, tvar)) v.flip else if (isLocalOnly(sym)) Bivariant - else if (sym.isAliasType) Invariant + else if (sym.isAliasType) ( + // Unsound pre-2.11 behavior preserved under -Xsource:2.10 + if (settings.isScala211 || sym.isOverridingSymbol) Invariant + else { + deprecationWarning(sym.pos, s"Construct depends on unsound variance analysis and will not compile in scala 2.11 and beyond") + Bivariant + } + ) else v ) def loop(sym: Symbol, v: Variance): Variance = ( |