diff options
author | Martin Odersky <odersky@gmail.com> | 2007-03-05 23:20:41 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-03-05 23:20:41 +0000 |
commit | 69a8cebb64fddaffe9059126cca0b35718d28bf8 (patch) | |
tree | 48d07fe33db25d63967b14d4d01ea090f22ca477 /src | |
parent | 93119cb1e79ca49c816cb7428e68d159a48c0369 (diff) | |
download | scala-69a8cebb64fddaffe9059126cca0b35718d28bf8.tar.gz scala-69a8cebb64fddaffe9059126cca0b35718d28bf8.tar.bz2 scala-69a8cebb64fddaffe9059126cca0b35718d28bf8.zip |
fixed bugs 973,971,949,947,946,930
Diffstat (limited to 'src')
4 files changed, 36 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 9c4dc59b96..837ba27e71 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -308,7 +308,9 @@ trait Scanners requires SyntaxAnalyzer { 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | - 'z' => + 'z' | + '0' | '1' | '2' | '3' | '4' | + '5' | '6' | '7' | '8' | '9' => putChar(in.ch) in.next if (in.ch != '\'') { diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 85186da712..ac8572c1d9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -811,16 +811,20 @@ trait Infer requires Analyzer { case SingleType(pre, _) => checkCheckable(pos, pre) case TypeRef(pre, sym, args) => - if (sym.isAbstractType) patternWarning(tp, "abstract type ") - else for (val arg <- args) { - if (sym == ArrayClass) checkCheckable(pos, arg) - else arg match { - case TypeRef(_, sym, _) if isLocalBinding(sym) => - ; - case _ => - patternWarning(arg, "non variable type-argument ") + if (sym.isAbstractType) + patternWarning(tp, "abstract type ") + else if (sym == AllClass || sym == AllRefClass) + error(pos, "this type cannot be used in a type pattern") + else + for (val arg <- args) { + if (sym == ArrayClass) checkCheckable(pos, arg) + else arg match { + case TypeRef(_, sym, _) if isLocalBinding(sym) => + ; + case _ => + patternWarning(arg, "non variable type-argument ") + } } - } checkCheckable(pos, pre) case RefinedType(parents, decls) => if (decls.isEmpty) for (val p <- parents) checkCheckable(pos, p) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 5d377b5a12..68c8bebcfa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -260,6 +260,9 @@ abstract class RefChecks extends InfoTransform { * <li> <!-- 3 --> * Check that at most one base type is a case-class. * </li> + * <li> <!-- 4 --> + * Check that inner classes do not inherit from Annotation + * </li> * </ol> */ private def validateBaseTypes(clazz: Symbol): unit = { @@ -291,6 +294,10 @@ abstract class RefChecks extends InfoTransform { " cannot be combined in one object"); seenCaseClass = baseClass } + // check that inner classes do not inherit from Annotation + if (baseClass == ClassfileAnnotationClass) + if (!clazz.owner.isPackageClass) + unit.error(clazz.pos, "inner classes cannot be classfile annotations") } validateTypes(tp.parents, includeSuper) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index fbf78cbe7d..cbd691ae3d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2019,7 +2019,7 @@ trait Typers requires Analyzer { mkTypeBounds(AllClass.tpe, AnyClass.tpe) if (vble.name == nme.WILDCARD.toTypeName) context.scope.enter(vble) else namer.enterInScope(vble) - tree setType vble.tpe + tree setSymbol vble setType vble.tpe } else { if (vble == NoSymbol) vble = context.owner.newValue(tree.pos, name) @@ -2196,7 +2196,9 @@ trait Typers requires Analyzer { case Typed(expr, tpt) => val tpt1 = typedType(tpt) val expr1 = typed(expr, mode & stickyModes, tpt1.tpe.deconst) - val owntype = if ((mode & PATTERNmode) != 0) inferTypedPattern(tpt1.pos, tpt1.tpe, widen(pt)) else tpt1.tpe + val owntype = + if ((mode & PATTERNmode) != 0) inferTypedPattern(tpt1.pos, tpt1.tpe, widen(pt)) + else tpt1.tpe //Console.println(typed pattern: "+tree+":"+", tp = "+tpt1.tpe+", pt = "+pt+" ==> "+owntype)//DEBUG copy.Typed(tree, expr1, tpt1) setType owntype @@ -2359,6 +2361,15 @@ trait Typers requires Analyzer { val argtypes = args1 map (.tpe) val owntype = if (tpt1.symbol.isClass) appliedType(tpt1.tpe, argtypes) else tpt1.tpe.subst(tparams, argtypes) + List.map2(args, tparams) { (arg, tparam) => arg match { + // note: can't use args1 in selector, because Bind's got replaced + case Bind(_, _) => + if (arg.symbol.isAbstractType) + arg.symbol setInfo + TypeBounds(lub(List(arg.symbol.info.bounds.lo, tparam.info.bounds.lo)), + glb(List(arg.symbol.info.bounds.hi, tparam.info.bounds.hi))) + case _ => + }} TypeTree(owntype) setOriginal(tree) // setPos tree.pos } else if (tparams.length == 0) { errorTree(tree, tpt1.tpe+" does not take type parameters") |