diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-03-14 12:33:15 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-03-14 12:33:15 -0700 |
commit | 014e4d909d5e8b8605229f1237aa175e27bf8475 (patch) | |
tree | 1ecb0f25de54d3502fe60ceef0da0d46e38d7550 | |
parent | efc0905f6b7a78bf3b454fbd9adb50aab5ffe20d (diff) | |
parent | 80fc8b7818205634caa3996b18b2fd156e9aabd8 (diff) | |
download | scala-014e4d909d5e8b8605229f1237aa175e27bf8475.tar.gz scala-014e4d909d5e8b8605229f1237aa175e27bf8475.tar.bz2 scala-014e4d909d5e8b8605229f1237aa175e27bf8475.zip |
Merge pull request #3623 from paulp/pr/source-210
SI-8402 Restore 2.10 variance behavior under -Xsource:2.10
-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 | ||||
-rw-r--r-- | test/files/neg/t8265.check | 6 | ||||
-rw-r--r-- | test/files/neg/t8265.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t8265.scala | 1 |
6 files changed, 20 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 = ( diff --git a/test/files/neg/t8265.check b/test/files/neg/t8265.check new file mode 100644 index 0000000000..7b1db1c4e5 --- /dev/null +++ b/test/files/neg/t8265.check @@ -0,0 +1,6 @@ +t8265.scala:1: warning: Construct depends on unsound variance analysis and will not compile in scala 2.11 and beyond +class Foo[+CC[X]] { type Coll = CC[_] } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t8265.flags b/test/files/neg/t8265.flags new file mode 100644 index 0000000000..9d7ba7abd8 --- /dev/null +++ b/test/files/neg/t8265.flags @@ -0,0 +1 @@ +-Xsource:2.10 -deprecation -language:higherKinds -Xfatal-warnings diff --git a/test/files/neg/t8265.scala b/test/files/neg/t8265.scala new file mode 100644 index 0000000000..a215903ebc --- /dev/null +++ b/test/files/neg/t8265.scala @@ -0,0 +1 @@ +class Foo[+CC[X]] { type Coll = CC[_] } |