diff options
author | Paul Phillips <paulp@improving.org> | 2012-12-31 12:36:04 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-09 12:11:13 -0800 |
commit | 91d8584fde15140972f7d6037d632bc24fc50f94 (patch) | |
tree | be48d686376c24648cb9a27abd323ed63f94254a /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | |
parent | 36ec5ff749a8148637129aa83d2cc597a773272b (diff) | |
download | scala-91d8584fde15140972f7d6037d632bc24fc50f94.tar.gz scala-91d8584fde15140972f7d6037d632bc24fc50f94.tar.bz2 scala-91d8584fde15140972f7d6037d632bc24fc50f94.zip |
Moved Variances into SymbolTable.
So I can centralize all the redundant variance code.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index eeb76dced2..704aebc50b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -38,7 +38,7 @@ import scala.language.postfixOps * * @todo Check whether we always check type parameter bounds. */ -abstract class RefChecks extends InfoTransform with scala.reflect.internal.transform.RefChecks with Variances { +abstract class RefChecks extends InfoTransform with scala.reflect.internal.transform.RefChecks { val global: Global // need to repeat here because otherwise last mixin defines global as // SymbolTable. If we had DOT this would not be an issue @@ -844,7 +844,16 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans // Variance Checking -------------------------------------------------------- - val varianceValidator = new VarianceValidator + object varianceValidator extends VarianceValidator { + private def tpString(tp: Type) = tp match { + case ClassInfoType(parents, _, clazz) => "supertype "+intersectionType(parents, clazz.owner) + case _ => "type "+tp + } + override def issueVarianceError(base: Symbol, sym: Symbol, required: Variance) { + currentRun.currentUnit.error(base.pos, + s"${sym.variance} $sym occurs in $required position in ${tpString(base.info)} of $base") + } + } // Forward reference checking --------------------------------------------------- |