From 96248ae593f34301de81970d6b7ba67d7bf31e04 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 5 Jan 2007 18:26:37 +0000 Subject: --- src/compiler/scala/tools/nsc/symtab/Types.scala | 4 +++- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/compiler') 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 thistp 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)) => -- cgit v1.2.3