summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-02-09 14:45:55 +0000
committerMartin Odersky <odersky@gmail.com>2007-02-09 14:45:55 +0000
commit152563b963992dc7a5d8eea863cf70fc2b540c52 (patch)
treec71c98df4b08bd52a0685b812483a5a609082c1c /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent7adcd11916bde8d603302913feb591f0a3c3d333 (diff)
downloadscala-152563b963992dc7a5d8eea863cf70fc2b540c52.tar.gz
scala-152563b963992dc7a5d8eea863cf70fc2b540c52.tar.bz2
scala-152563b963992dc7a5d8eea863cf70fc2b540c52.zip
made subtyping decidable.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index dff9b8d6c2..18c9adda86 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -809,6 +809,25 @@ trait Typers requires Analyzer {
for (val p <- parents) validateParentClass(p, parents.head.tpe.symbol)
}
+ def checkFinitary(classinfo: ClassInfoType) {
+ val clazz = classinfo.symbol
+ for (val tparam <- clazz.typeParams) {
+ if (classinfo.expansiveRefs(tparam) contains tparam) {
+ error(tparam.pos, "class graph is not finitary because type parameter "+tparam.name+" is expansively recursive")
+ val newinfo = ClassInfoType(
+ classinfo.parents map (.subst(List(tparam), List(AnyRefClass.tpe))),
+ classinfo.decls,
+ clazz)
+ clazz.setInfo {
+ clazz.info match {
+ case PolyType(tparams, _) => PolyType(tparams, newinfo)
+ case _ => newinfo
+ }
+ }
+ }
+ }
+ }
+
/**
* @param cdef ...
* @return ...
@@ -914,6 +933,8 @@ trait Typers requires Analyzer {
// the following is necessary for templates generated later
enterSyms(context.outer.make(templ, clazz, clazz.info.decls), templ.body)
validateParentClasses(parents1, selfType)
+ if (!phase.erasedTypes)
+ checkFinitary(clazz.info.resultType.asInstanceOf[ClassInfoType])
val body =
if (phase.id <= currentRun.typerPhase.id && !reporter.hasErrors)
templ.body flatMap addGetterSetter