diff options
author | Martin Odersky <odersky@gmail.com> | 2008-02-22 17:26:28 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-02-22 17:26:28 +0000 |
commit | a8f9f01d5e2e24c0280f4010a1448e7f758064d2 (patch) | |
tree | 23ea2a690b3936cd7b2b825a06d3d147ba407d3d /src | |
parent | 21221df10011e3479bb066b4d61ae2e1a2b44559 (diff) | |
download | scala-a8f9f01d5e2e24c0280f4010a1448e7f758064d2.tar.gz scala-a8f9f01d5e2e24c0280f4010a1448e7f758064d2.tar.bz2 scala-a8f9f01d5e2e24c0280f4010a1448e7f758064d2.zip |
no singleton types allowed in new.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index ac7a40ba4f..41a96d3e5c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -236,9 +236,14 @@ trait Typers { self: Analyzer => if (treeInfo.isPureExpr(tree)) tree else errorTree(tree, "stable identifier required, but " + tree + " found.") - /** Check that `sym' refers to a non-refinement class type */ - def checkClassType(pos: Position, sym: Symbol) { - if (!sym.isClass || sym.isRefinementClass) error(pos, "class type required") + /** Check that `tpt' refers to a non-refinement class type */ + def checkClassType(tpt: Tree) { + def check(tpe: Type): Unit = tpe.normalize match { + case TypeRef(_, sym, _) if sym.isClass && !sym.isRefinementClass => ; + case PolyType(_, restpe) => check(restpe) + case t => error(tpt.pos, "class type required but "+t+" found") + } + check(tpt.tpe) } /** Check that type <code>tp</code> is not a subtype of itself. @@ -951,7 +956,7 @@ trait Typers { self: Analyzer => def validateParentClass(parent: Tree, superclazz: Symbol) { if (!parent.tpe.isError) { val psym = parent.tpe.typeSymbol.initialize - checkClassType(parent.pos, psym) + checkClassType(parent) if (psym != superclazz) { if (psym.isTrait) { val ps = psym.info.parents @@ -2296,6 +2301,7 @@ trait Typers { self: Analyzer => def typedNew(tpt: Tree) = { var tpt1 = typedTypeConstructor(tpt) + checkClassType(tpt1) if (tpt1.hasSymbol && !tpt1.symbol.typeParams.isEmpty) { context.undetparams = cloneSymbols(tpt1.symbol.typeParams) tpt1 = TypeTree() @@ -2375,7 +2381,7 @@ trait Typers { self: Analyzer => val targs = args map (_.tpe) checkBounds(tree.pos, NoPrefix, NoSymbol, tparams, targs, "") if (fun.symbol == Predef_classOf) { - checkClassType(args.head.pos, targs.head.typeSymbol) + checkClassType(args.head) Literal(Constant(targs.head)) setPos tree.pos setType Predef_classOfType(targs.head) // @M: targs.head.normalize is not necessary --> toTypeKind eventually normalizes the type } else { |