diff options
author | Martin Odersky <odersky@gmail.com> | 2007-02-19 16:34:11 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-02-19 16:34:11 +0000 |
commit | 53c115ff4c8a6cf81659e0ac7bb878b32765107a (patch) | |
tree | 01c06cfac1acc49c78d6ec578a755a7cd73c0666 /src/compiler/scala/tools/nsc/typechecker/Namers.scala | |
parent | f1e1fcc733c025710368cdba5648954ef1057d80 (diff) | |
download | scala-53c115ff4c8a6cf81659e0ac7bb878b32765107a.tar.gz scala-53c115ff4c8a6cf81659e0ac7bb878b32765107a.tar.bz2 scala-53c115ff4c8a6cf81659e0ac7bb878b32765107a.zip |
fixed bugs 954/958/957, plus problem with the i...
fixed bugs 954/958/957, plus problem with the interpreter.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Namers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 70 |
1 files changed, 8 insertions, 62 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 000c57d766..17b22403c4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -567,13 +567,19 @@ trait Namers requires Analyzer { makePolyType(typer.reenterTypeParams(tparams), typer.typedType(rhs).tpe); def typeSig(tree: Tree): Type = { + val sym: Symbol = tree.symbol tree match { - case md: MemberDef => attributes(md) + case defn: MemberDef => + val annots = for { + val Annotation(constr, elements) <- defn.mods.attributes + val ainfo = typer.typedAnnotation(constr, elements) + !ainfo.atp.isError + } yield ainfo + if (!annots.isEmpty) sym.attributes = annots case _ => } val result = try { - val sym: Symbol = tree.symbol tree match { case ClassDef(_, _, tparams, self, impl) => new Namer(makeNewScope(context, tree, sym)).classSig(tparams, self, impl) @@ -666,66 +672,6 @@ trait Namers requires Analyzer { deSkolemize(result) } - /** - * @param defn ... - */ - protected def attributes(defn: MemberDef): Unit = { - var attrError: Boolean = false; - def error(pos: PositionType, msg: String): Null = { - context.error(pos, msg) - attrError = true - null - } - def getConstant(tree: Tree): Constant = tree match { - case Literal(value) => value - case arg => error(arg.pos, "attribute argument needs to be a constant; found: "+arg) - } - val attrInfos = - for (val t @ Annotation(constr, elements) <- defn.mods.attributes) yield { - typer.typed(constr, EXPRmode | CONSTmode, AnnotationClass.tpe) match { - case Apply(Select(New(tpt), nme.CONSTRUCTOR), args) => - val constrArgs = args map getConstant - val attrScope = tpt.tpe.decls. - filter(sym => sym.isMethod && !sym.isConstructor && sym.hasFlag(JAVA)); - val names = new collection.mutable.HashSet[Symbol] - names ++= attrScope.elements.filter(.isMethod) - if (args.length == 1) { - names.retain(sym => sym.name != nme.value) - } - val nvPairs = elements map { - case Assign(ntree @ Ident(name), rhs) => { - val sym = attrScope.lookup(name); - if (sym == NoSymbol) { - error(ntree.pos, "unknown attribute element name: " + name) - } else if (!names.contains(sym)) { - error(ntree.pos, "duplicate value for element " + name) - } else { - names -= sym - Pair(sym.name, getConstant(typer.typed(rhs, EXPRmode | CONSTmode, sym.tpe.resultType))) - } - } - } - for (val name <- names) { - if (!name.attributes.contains(Triple(AnnotationDefaultAttr.tpe, List(), List()))) { - error(t.pos, "attribute " + tpt.tpe.symbol.fullNameString + " is missing element " + name.name) - } - } - if (tpt.tpe.symbol.hasFlag(JAVA) && settings.target.value == "jvm-1.4") { - context.unit.warning (t.pos, "Java annotation will not be emitted in classfile unless you use the '-target:jvm-1.5' option") - } - AttrInfo(tpt.tpe, constrArgs, nvPairs) - } - } - if (!attrError) { - val attributed = - if (defn.symbol.isModule) defn.symbol.moduleClass else defn.symbol - if (!attrInfos.isEmpty) { - attributed.attributes = attrInfos - } - } -// defn.mods setAttr List(); - } - /** Check that symbol's definition is well-formed. This means: * - no conflicting modifiers * - `abstract' modifier only for classes |