summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-02-22 11:32:42 +0000
committerMartin Odersky <odersky@gmail.com>2008-02-22 11:32:42 +0000
commit07c5d167ad0cde416217f19d3ecb342054a507a0 (patch)
tree972d133cb85a1d224caea92d00d1507fccbecfa0
parentfb914227c50c4175ef1603b99ae4bc05839b4e51 (diff)
downloadscala-07c5d167ad0cde416217f19d3ecb342054a507a0.tar.gz
scala-07c5d167ad0cde416217f19d3ecb342054a507a0.tar.bz2
scala-07c5d167ad0cde416217f19d3ecb342054a507a0.zip
allow value overrides in traits; check variance...
allow value overrides in traits; check variances in existential types (see #528)
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala6
2 files changed, 8 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index fa37dd5786..a689aa6fd5 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -182,9 +182,9 @@ abstract class RefChecks extends InfoTransform {
overrideError("cannot override a mutable variable")
} else if (other.isStable && !member.isStable) { // (1.4)
overrideError("needs to be an immutable value")
- } else if (other.isStable && !other.isDeferred && other.owner.isTrait && (member hasFlag OVERRIDE)) {
- overrideError("cannot override a value or variable definition in a trait " +
- "\n (this is an implementation restriction)")
+// } else if (other.isStable && !other.isDeferred && other.owner.isTrait && (member hasFlag OVERRIDE)) {
+// overrideError("cannot override a value or variable definition in a trait " +
+// "\n (this is an implementation restriction)")
} else {
if (other.isAliasType) {
//if (!member.typeParams.isEmpty) // (1.5) @MAT
@@ -405,8 +405,10 @@ abstract class RefChecks extends InfoTransform {
case MethodType(formals, result) =>
validateVariance(result, variance)
case PolyType(tparams, result) =>
+ // type parameters will be validated separately, because they are defined explicitly.
validateVariance(result, variance)
case ExistentialType(tparams, result) =>
+ validateVariances(tparams map (_.info), variance)
validateVariance(result, variance)
case AnnotatedType(attribs, tp, selfsym) =>
validateVariance(tp, variance)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 806698dd65..ac7a40ba4f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2252,9 +2252,9 @@ trait Typers { self: Analyzer =>
} else {
if (!lhs1.tpe.isError) {
//println(lhs1+" = "+rhs)//DEBUG
- error(tree.pos, "assignment to "+
- (if ((varsym ne null) && varsym.isValue) "immutable value"
- else "non variable"))
+ error(tree.pos,
+ if ((varsym ne null) && varsym.isValue) "reassignment to val"
+ else "assignment to non variable")
}
setError(tree)
}