diff options
author | Martin Odersky <odersky@gmail.com> | 2007-01-05 18:26:37 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-01-05 18:26:37 +0000 |
commit | 96248ae593f34301de81970d6b7ba67d7bf31e04 (patch) | |
tree | 286aa940fddcc4c35d6daecbcc8374aff9bb2bf0 | |
parent | 114bfa60ec5c24a270de9b9fea4171f3c9afc5e6 (diff) | |
download | scala-96248ae593f34301de81970d6b7ba67d7bf31e04.tar.gz scala-96248ae593f34301de81970d6b7ba67d7bf31e04.tar.bz2 scala-96248ae593f34301de81970d6b7ba67d7bf31e04.zip |
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 7863e4c714..ebef3e87b5 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -2234,7 +2234,8 @@ trait Types requires SymbolTable { // which are refined by every type in ts. if (!sym.isClass && !sym.isConstructor && (narrowts forall (t => refines(t, sym)))) try { - addMember(lubThisType, lubType, lubsym(sym)) + val lsym = lubsym(sym) + if (lsym != NoSymbol) addMember(lubThisType, lubType, lubsym(sym)) } catch { case ex: NoCommonType => } @@ -2403,6 +2404,7 @@ trait Types requires SymbolTable { * where <code>thistp</code> is the narrowed owner type of the scope. */ def addMember(thistp: Type, tp: Type, sym: Symbol): unit = { + assert(sym != NoSymbol) if (settings.debug.value) log("add member " + sym)//debug if (!(thistp specializes sym)) { if (sym.isTerm) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index a55ba1045e..17723218d9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1955,8 +1955,12 @@ trait Typers requires Analyzer { .setType(appliedType(tpt1.tpe, context.undetparams map (.tpe))) } if (tpt1.tpe.symbol hasFlag ABSTRACT) - error(tree.pos, "" + tpt1.tpe.symbol + + error(tree.pos, tpt1.tpe.symbol + " is abstract; cannot be instantiated") + else if (!(tpt1.tpe <:< tpt1.tpe.typeOfThis) && !phase.erasedTypes) + error(tree.pos, tpt1.tpe.symbol + + " cannot be instantiated because it does not conform to its self-type "+ + tpt1.tpe.typeOfThis) copy.New(tree, tpt1).setType(tpt1.tpe) case Typed(expr, Function(List(), EmptyTree)) => |