summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-10-26 17:26:45 +0000
committerMartin Odersky <odersky@gmail.com>2007-10-26 17:26:45 +0000
commite97eb8f50e2ae30c3a651b7f975282659a57e817 (patch)
tree5835476f458a667bc24576b1e550ec6f760f00ef /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parent74c60ffa67853c170e4f23e500c0380a2118c8b4 (diff)
downloadscala-e97eb8f50e2ae30c3a651b7f975282659a57e817.tar.gz
scala-e97eb8f50e2ae30c3a651b7f975282659a57e817.tar.bz2
scala-e97eb8f50e2ae30c3a651b7f975282659a57e817.zip
fixed tickets 152, 123.
spreadsheet demo crash. Made Lists more tail recursive. toString in Sets and Maps now says just Set(...) or Map(...) without revealing the implementation.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala51
1 files changed, 24 insertions, 27 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 695cb60f5e..df34651883 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -316,41 +316,38 @@ abstract class RefChecks extends InfoTransform {
val seenTypes = new Array[Type](clazz.info.closure.length)
var seenCaseClass = if (clazz hasFlag CASE) clazz else NoSymbol
- def validateTypes(tps: List[Type], includeSuper: Boolean) {
- if (!tps.isEmpty) {
- for (val tp <- tps.tail.reverse) validateType(tp, false);
- if (includeSuper) validateType(tps.head, true);
- }
- }
-
- def validateType(tp: Type, includeSuper: Boolean) {
+ /** validate all base types of a class in reverse linear order. */
+ def validateType(tp: Type) {
val baseClass = tp.typeSymbol
if (baseClass.isClass) {
val index = clazz.info.closurePos(baseClass)
if (index >= 0) {
- if ((seenTypes(index) ne null) && !(seenTypes(index) <:< tp))
- unit.error(clazz.pos, "illegal inheritance;\n " + clazz +
- " inherits different type instances of " + baseClass +
- ":\n" + tp + " and " + seenTypes(index));
- seenTypes(index) = tp;
- // check that case classes do not inherit from case classes
- if (baseClass hasFlag CASE) {
- if (seenCaseClass != NoSymbol && seenCaseClass != baseClass)
- unit.error(clazz.pos, "implementation restriction: case " +
- seenCaseClass + " and case " + baseClass +
- " cannot be combined in one object");
- seenCaseClass = baseClass
+ if (seenTypes(index) ne null) {
+ if (!(seenTypes(index) <:< tp)) {
+ unit.error(clazz.pos, "illegal inheritance;\n " + clazz +
+ " inherits different type instances of " + baseClass +
+ ":\n" + tp + " and " + seenTypes(index));
+ }
+ } else {
+ seenTypes(index) = tp
+ // check that case classes do not inherit from case classes
+ if (baseClass hasFlag CASE) {
+ if (seenCaseClass != NoSymbol && seenCaseClass != baseClass)
+ unit.error(clazz.pos, "implementation restriction: case " +
+ seenCaseClass + " and case " + baseClass +
+ " cannot be combined in one object");
+ seenCaseClass = baseClass
+ }
+ // check that inner classes do not inherit from Annotation
+ if (baseClass == ClassfileAnnotationClass)
+ if (!clazz.owner.isPackageClass)
+ unit.error(clazz.pos, "inner classes cannot be classfile annotations")
}
- // check that inner classes do not inherit from Annotation
- if (baseClass == ClassfileAnnotationClass)
- if (!clazz.owner.isPackageClass)
- unit.error(clazz.pos, "inner classes cannot be classfile annotations")
+ tp.parents foreach validateType
}
- validateTypes(tp.parents, includeSuper)
}
}
-
- validateTypes(clazz.info.parents, true)
+ validateType(clazz.tpe)
}
// Variance Checking --------------------------------------------------------