summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-03-12 13:41:18 +0000
committerMartin Odersky <odersky@gmail.com>2006-03-12 13:41:18 +0000
commit9beb585e554200d3ef7a8733df77040551218d86 (patch)
tree7e68218e581d8ef86f74cf89d7f782eca04c0303 /src
parent7cb7defbd4063d6c4cbd42a9222f51fe09346dab (diff)
downloadscala-9beb585e554200d3ef7a8733df77040551218d86.tar.gz
scala-9beb585e554200d3ef7a8733df77040551218d86.tar.bz2
scala-9beb585e554200d3ef7a8733df77040551218d86.zip
Fixed some more bugs and improved error messages.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala7
3 files changed, 20 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 6ab9822d15..2e805dd5e3 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1097,6 +1097,10 @@ trait Types requires SymbolTable {
if (lobounds.forall(.<:<(tp)) && hibounds.forall(tp.<:<)) {
inst = tp; true
} else false;
+
+ override def toString() =
+ lobounds.mkString("[ _>:(", ",", ") ")+
+ hibounds.mkString("| _<:(", ",", ") | _= ")+ inst;
}
/** A prototype for mapping a function over all possible types
@@ -1240,7 +1244,11 @@ trait Types requires SymbolTable {
case TypeRef(_, basesym, baseargs) =>
// System.out.println("instantiating " + sym + " from " + basesym + " with " + basesym.typeParams + " and " + baseargs);//DEBUG
if (basesym.typeParams.length != baseargs.length)
- assert(false, "asSeenFrom(" + pre + "," + clazz + ")" + sym + " " + basesym + " " + baseargs); //debug
+ throw new TypeError(
+ "something is wrong (wrong class file?): "+basesym+
+ " with type parameters "+
+ basesym.typeParams.map(.name).mkString("[",",","]")+
+ " gets applied to arguments "+baseargs.mkString("(",",",")"))
instParam(basesym.typeParams, baseargs);
case _ =>
throwError
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 1004b4b67d..5df8be1170 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -246,6 +246,7 @@ trait Infer requires Analyzer {
errorTree(tree, sym.toString() + " cannot be accessed in " +
(if (sym.isClassConstructor) context.enclClass.owner else pre.widen))
} else {
+ //System.out.println("check acc " + sym1 + ":" + sym1.tpe + " from " + pre);//DEBUG
var owntype = pre.memberType(sym1);
if (pre.isInstanceOf[SuperType])
owntype = owntype.substSuper(pre, site.symbol.thisType);
@@ -295,8 +296,9 @@ trait Infer requires Analyzer {
def protoTypeArgs(tparams: List[Symbol], formals: List[Type], restpe: Type,
pt: Type): List[Type] = {
/** Map type variable to its instance, or, if `variance' is covariant/contravariant,
- * to its upper/lower bound; */
+ * to its upper/lower bound */
def instantiateToBound(tvar: TypeVar, variance: int): Type = try {
+ //System.out.println("instantiate "+tvar+tvar.constr+" variance = "+variance);//DEBUG
if (tvar.constr.inst != NoType) {
instantiate(tvar.constr.inst)
} else if ((variance & COVARIANT) != 0 && !tvar.constr.hibounds.isEmpty) {
@@ -305,6 +307,10 @@ trait Infer requires Analyzer {
} else if ((variance & CONTRAVARIANT) != 0 && !tvar.constr.lobounds.isEmpty) {
tvar.constr.inst = lub(tvar.constr.lobounds);
instantiate(tvar.constr.inst)
+ } else if (!tvar.constr.hibounds.isEmpty && !tvar.constr.lobounds.isEmpty &&
+ glb(tvar.constr.hibounds) <:< lub(tvar.constr.lobounds)) {
+ tvar.constr.inst = glb(tvar.constr.hibounds);
+ instantiate(tvar.constr.inst)
} else {
WildcardType
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 7d1b5a9c78..63edcdb412 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -567,10 +567,11 @@ trait Typers requires Analyzer {
error(parent.pos, "illegal inheritance; super"+superclazz+
"\n is not a subclass of the super"+ps.head.symbol+
"\n of the mixin " + psym);
- } else if (settings.migrate.value)
+ } else if (settings.migrate.value) {
error(parent.pos, migrateMsg+psym+" needs to be a declared as a trait")
- else
- error(parent.pos, ""+psym+" is not declared to be a trait")
+ }else {
+ error(parent.pos, ""+psym+" needs to be a trait be mixed in")
+ }
else if (psym.hasFlag(FINAL))
error(parent.pos, "illegal inheritance from final class")
else if (!phase.erasedTypes && psym.isSealed &&