diff options
author | Martin Odersky <odersky@gmail.com> | 2007-02-27 22:21:22 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-02-27 22:21:22 +0000 |
commit | 0b433a78b45aa63c0218d8af51bb5c4098e562d2 (patch) | |
tree | 58e46c8f3270ee5fc25d3056234859592fba73d8 | |
parent | 54f0202e2940501862e7dff52e82de14aa3fa1ab (diff) | |
download | scala-0b433a78b45aa63c0218d8af51bb5c4098e562d2.tar.gz scala-0b433a78b45aa63c0218d8af51bb5c4098e562d2.tar.bz2 scala-0b433a78b45aa63c0218d8af51bb5c4098e562d2.zip |
fixed bug968, improved an error message
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/StdNames.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/LambdaLift.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 11 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index 8ab60f8459..91b9cd163a 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -65,7 +65,7 @@ trait StdNames requires SymbolTable { val HASHkw = newTermName("#") val ATkw = newTermName("@") - val LOCALDUMMY_PREFIX_STRING = "local$" + val LOCALDUMMY_PREFIX_STRING = "<local " val SUPER_PREFIX_STRING = "super$" val EXPAND_SEPARATOR_STRING = "$$" val TUPLE_FIELD_PREFIX_STRING = "_" @@ -73,7 +73,7 @@ trait StdNames requires SymbolTable { val INTERPRETER_WRAPPER_SUFFIX = "$object" val INTERPRETER_LINE_PREFIX = "line" - def LOCAL(clazz: Symbol) = newTermName(LOCALDUMMY_PREFIX_STRING + clazz.name) + def LOCAL(clazz: Symbol) = newTermName(LOCALDUMMY_PREFIX_STRING + clazz.name+">") def TUPLE_FIELD(index: int) = newTermName(TUPLE_FIELD_PREFIX_STRING + index) val LOCAL_SUFFIX = newTermName(" ") diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index 9d370bcc6f..6759e24e08 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -101,8 +101,9 @@ abstract class LambdaLift extends InfoTransform { def localToConstr(sym: Symbol) = if (sym.isLocalDummy) sym.owner.primaryConstructor else sym; var encl = localToConstr(sym) - while (!encl.isMethod && !encl.isClass) + while (!encl.isMethod && !encl.isClass) { encl = localToConstr(outer(encl)); + } encl } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 5ca41780ab..2d6ffbb099 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -725,6 +725,7 @@ trait Typers requires Analyzer { if (templ.parents.isEmpty) List() else { var supertpt = typedTypeConstructor(templ.parents.head) + val firstParent = supertpt.tpe.symbol var mixins = templ.parents.tail map typedType // If first parent is a trait, make it first mixin and add its superclass as first parent while ((supertpt.tpe.symbol ne null) && supertpt.tpe.symbol.initialize.isTrait) { @@ -734,10 +735,18 @@ trait Typers requires Analyzer { supertpt = TypeTree(supertpt1.tpe.parents.head) setOriginal supertpt /* setPos supertpt.pos */ } } + val constr = treeInfo.firstConstructor(templ.body) + if (supertpt.tpe.symbol != firstParent) { + constr match { + case DefDef(_, _, _, _, _, Apply(_, superargs)) => + if (!superargs.isEmpty) + error(superargs.head.pos, firstParent+" is a trait; does not take constructor arguments") + case _ => + } + } if (supertpt.hasSymbol) { val tparams = supertpt.symbol.typeParams if (!tparams.isEmpty) { - val constr = treeInfo.firstConstructor(templ.body) constr match { case EmptyTree => error(supertpt.pos, "missing type arguments") |