summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-11-11 18:40:55 +0000
committerMartin Odersky <odersky@gmail.com>2007-11-11 18:40:55 +0000
commit9c0994d031fa416ea6e5e7bc147bbd5f640e1881 (patch)
tree658a94c04993cd4d2df99af2007694e37c9aa140 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent5bd7d8413a47d8c0806e42a1dc8de2bdde507bc5 (diff)
downloadscala-9c0994d031fa416ea6e5e7bc147bbd5f640e1881.tar.gz
scala-9c0994d031fa416ea6e5e7bc147bbd5f640e1881.tar.bz2
scala-9c0994d031fa416ea6e5e7bc147bbd5f640e1881.zip
Fixed #204 and #207
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index f780293e78..ff4da33293 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -241,6 +241,11 @@ 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 type <code>tp</code> is not a subtype of itself.
*
* @param pos ...
@@ -938,9 +943,8 @@ trait Typers { self: Analyzer =>
def validateParentClass(parent: Tree, superclazz: Symbol) {
if (!parent.tpe.isError) {
val psym = parent.tpe.typeSymbol.initialize
- if (!psym.isClass) {
- error(parent.pos, "class type expected")
- } else if (psym != superclazz) {
+ checkClassType(parent.pos, psym)
+ if (psym != superclazz) {
if (psym.isTrait) {
val ps = psym.info.parents
if (!ps.isEmpty && !superclazz.isSubClass(ps.head.typeSymbol))
@@ -2237,8 +2241,7 @@ trait Typers { self: Analyzer =>
val targs = args map (_.tpe)
checkBounds(tree.pos, NoPrefix, NoSymbol, tparams, targs, "")
if (fun.symbol == Predef_classOf) {
- if (!targs.head.typeSymbol.isClass || targs.head.typeSymbol.isRefinementClass)
- error(args.head.pos, "class type required");
+ checkClassType(args.head.pos, targs.head.typeSymbol)
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 {