From 223bcfc6abf53a2239692d7299409991b805efaa Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Thu, 29 Oct 2009 14:02:06 +0000 Subject: AnnotationInfo.pos no longer in constructor. --- .../scala/tools/nsc/CompilationUnits.scala | 3 --- .../scala/tools/nsc/backend/jvm/GenJVM.scala | 22 +++++++++++----------- .../scala/tools/nsc/backend/msil/GenMSIL.scala | 6 +++--- src/compiler/scala/tools/nsc/doc/ModelToXML.scala | 2 +- .../scala/tools/nsc/symtab/AnnotationInfos.scala | 11 +++++++++-- src/compiler/scala/tools/nsc/symtab/Symbols.scala | 2 +- src/compiler/scala/tools/nsc/symtab/Types.scala | 6 +++--- .../nsc/symtab/classfile/ClassfileParser.scala | 4 ++-- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 10 +++++----- .../tools/nsc/symtab/classfile/UnPickler.scala | 2 +- .../scala/tools/nsc/transform/CleanUp.scala | 6 +++--- src/compiler/scala/tools/nsc/transform/Mixin.scala | 2 +- .../tools/nsc/transform/SpecializeTypes.scala | 2 +- .../scala/tools/nsc/typechecker/Namers.scala | 4 ++-- .../tools/nsc/typechecker/SyntheticMethods.scala | 3 +-- .../scala/tools/nsc/typechecker/Typers.scala | 8 ++++---- 16 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index 4640b15158..e594a06efa 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -47,9 +47,6 @@ trait CompilationUnits { self: Global => /** things to check at end of compilation unit */ val toCheck = new ListBuffer[() => Unit] - /** used to track changes in a signature */ - var pickleHash : Long = 0 - def position(pos: Int) = source.position(pos) /** The position of a targeted type check diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index d66117c034..415a56712a 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -171,13 +171,13 @@ abstract class GenJVM extends SubComponent { parents = definitions.ObjectClass.tpe :: parents; for (annot <- c.symbol.annotations) annot match { - case AnnotationInfo(tp, _, _, _) if tp.typeSymbol == SerializableAttr => + case AnnotationInfo(tp, _, _) if tp.typeSymbol == SerializableAttr => parents = parents ::: List(definitions.SerializableClass.tpe) - case AnnotationInfo(tp, _, _, _) if tp.typeSymbol == CloneableAttr => + case AnnotationInfo(tp, _, _) if tp.typeSymbol == CloneableAttr => parents = parents ::: List(CloneableClass.tpe) - case AnnotationInfo(tp, Literal(const) :: _, _, _) if tp.typeSymbol == SerialVersionUID => + case AnnotationInfo(tp, Literal(const) :: _, _) if tp.typeSymbol == SerialVersionUID => serialVUID = Some(const.longValue) - case AnnotationInfo(tp, _, _, _) if tp.typeSymbol == RemoteAttr => + case AnnotationInfo(tp, _, _) if tp.typeSymbol == RemoteAttr => parents = parents ::: List(RemoteInterface.tpe) remoteClass = true case _ => () @@ -330,7 +330,7 @@ abstract class GenJVM extends SubComponent { // put some radom value; the actual number is determined at the end buf.putShort(0xbaba.toShort) - for (AnnotationInfo(tp, List(exc), _, _) <- excs.removeDuplicates if tp.typeSymbol == ThrowsAttr) { + for (AnnotationInfo(tp, List(exc), _) <- excs.removeDuplicates if tp.typeSymbol == ThrowsAttr) { val Literal(const) = exc buf.putShort( cpool.addClass( @@ -402,7 +402,7 @@ abstract class GenJVM extends SubComponent { } def emitAnnotation(annotInfo: AnnotationInfo) { - val AnnotationInfo(typ, args, assocs, _) = annotInfo + val AnnotationInfo(typ, args, assocs) = annotInfo val jtype = javaType(typ) buf.putShort(cpool.addUtf8(jtype.getSignature()).toShort) assert(args.isEmpty, args.toString) @@ -537,9 +537,9 @@ abstract class GenJVM extends SubComponent { var attributes = 0 f.symbol.annotations foreach { a => a match { - case AnnotationInfo(tp, _, _, _) if tp.typeSymbol == TransientAtt => + case AnnotationInfo(tp, _, _) if tp.typeSymbol == TransientAtt => attributes = attributes | JAccessFlags.ACC_TRANSIENT - case AnnotationInfo(tp, _, _, _) if tp.typeSymbol == VolatileAttr => + case AnnotationInfo(tp, _, _) if tp.typeSymbol == VolatileAttr => attributes = attributes | JAccessFlags.ACC_VOLATILE case _ => (); }} @@ -622,7 +622,7 @@ abstract class GenJVM extends SubComponent { private def addRemoteException(jmethod: JMethod, meth: Symbol) { def isRemoteThrows(ainfo: AnnotationInfo) = ainfo match { - case AnnotationInfo(tp, List(arg), _, _) if tp.typeSymbol == ThrowsAttr => + case AnnotationInfo(tp, List(arg), _) if tp.typeSymbol == ThrowsAttr => arg match { case Literal(Constant(tpe: Type)) if tpe.typeSymbol == RemoteException.typeSymbol => true case _ => false @@ -633,7 +633,7 @@ abstract class GenJVM extends SubComponent { if (remoteClass || (meth.hasAnnotation(RemoteAttr) && jmethod.isPublic())) { val c = Constant(RemoteException) - val ainfo = AnnotationInfo(ThrowsAttr.tpe, List(Literal(c).setType(c.tpe)), List(), NoPosition) + val ainfo = AnnotationInfo(ThrowsAttr.tpe, List(Literal(c).setType(c.tpe)), List()) if (!meth.annotations.exists(isRemoteThrows)) { meth.addAnnotation(ainfo) } @@ -646,7 +646,7 @@ abstract class GenJVM extends SubComponent { */ private def splitAnnotations(annotations: List[AnnotationInfo], annotSym: Symbol): (List[AnnotationInfo], List[AnnotationInfo]) = { annotations.partition { a => a match { - case AnnotationInfo(tp, _, _, _) if tp.typeSymbol == annotSym => true + case AnnotationInfo(tp, _, _) if tp.typeSymbol == annotSym => true case _ => false }} } diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 96d165339b..bbc11037ce 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -1849,7 +1849,7 @@ abstract class GenMSIL extends SubComponent { mf = mf | (if (sym isFinal) TypeAttributes.Sealed else 0) sym.annotations foreach { a => a match { - case AnnotationInfo(SerializableAttr, _, _, _) => + case AnnotationInfo(SerializableAttr, _, _) => // TODO: add the Serializable TypeAttribute also if the annotation // System.SerializableAttribute is present (.net annotation, not scala) // Best way to do it: compare with @@ -1899,7 +1899,7 @@ abstract class GenMSIL extends SubComponent { // TODO: add this annotation also if the class has the custom attribute // System.NotSerializedAttribute sym.annotations.foreach( a => a match { - case AnnotationInfo(TransientAtt, _, _, _) => + case AnnotationInfo(TransientAtt, _, _) => mf = mf | FieldAttributes.NotSerialized case _ => () }) @@ -2118,7 +2118,7 @@ abstract class GenMSIL extends SubComponent { private def isCloneable(sym: Symbol): Boolean = { !sym.annotations.forall( a => a match { - case AnnotationInfo(CloneableAttr, _, _, _) => false + case AnnotationInfo(CloneableAttr, _, _) => false case _ => true }) } diff --git a/src/compiler/scala/tools/nsc/doc/ModelToXML.scala b/src/compiler/scala/tools/nsc/doc/ModelToXML.scala index 75f85bf528..19d67ab2fd 100644 --- a/src/compiler/scala/tools/nsc/doc/ModelToXML.scala +++ b/src/compiler/scala/tools/nsc/doc/ModelToXML.scala @@ -349,7 +349,7 @@ trait ModelToXML extends ModelExtractor { def attrsFor(entity: Entity)(implicit from: Frame): NodeSeq = { def attrFor(attr: AnnotationInfo): Node = { val buf = new StringBuilder - val AnnotationInfo(tpe, args, nvPairs, _) = attr + val AnnotationInfo(tpe, args, nvPairs) = attr val name = link(decode(tpe.typeSymbol)) if (!args.isEmpty) buf.append(args.mkString("(", ",", ")")) diff --git a/src/compiler/scala/tools/nsc/symtab/AnnotationInfos.scala b/src/compiler/scala/tools/nsc/symtab/AnnotationInfos.scala index 211e9ea6aa..dd0c32cee2 100644 --- a/src/compiler/scala/tools/nsc/symtab/AnnotationInfos.scala +++ b/src/compiler/scala/tools/nsc/symtab/AnnotationInfos.scala @@ -75,12 +75,19 @@ trait AnnotationInfos { *

*/ case class AnnotationInfo(atp: Type, args: List[Tree], - assocs: List[(Name, ClassfileAnnotArg)], pos : Position) + assocs: List[(Name, ClassfileAnnotArg)]) extends AnnotationInfoBase { // Classfile annot: args empty. Scala annot: assocs empty. assert(args.isEmpty || assocs.isEmpty) + private var rawpos: Position = NoPosition + def pos = rawpos + def setPos(pos: Position): this.type = { + rawpos = pos + this + } + override def toString: String = atp + (if (!args.isEmpty) args.mkString("(", ", ", ")") else "") + (if (!assocs.isEmpty) (assocs map { case (x, y) => x+" = "+y } mkString ("(", ", ", ")")) else "") @@ -95,7 +102,7 @@ trait AnnotationInfos { /** Change all ident's with Symbol "from" to instead use symbol "to" */ def substIdentSyms(from: Symbol, to: Symbol) = { val subs = new TreeSymSubstituter(List(from), List(to)) - AnnotationInfo(atp, args.map(subs(_)), assocs, pos) + AnnotationInfo(atp, args.map(subs(_)), assocs).setPos(pos) } } diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index bf2ff9d9a3..9293ab4c3f 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -116,7 +116,7 @@ trait Symbols { // see "def typeSig" in Namers val annots1 = initialize.rawannots map { case LazyAnnotationInfo(annot) => annot() - case a @ AnnotationInfo(_, _, _, _) => a + case a @ AnnotationInfo(_, _, _) => a } filter { a => !a.atp.isError } rawannots = annots1 annots1 diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 83ab46db9d..4d7d200c58 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -2173,7 +2173,7 @@ A type's typeSymbol should never be inspected directly. // ** Replace formal type parameter symbols with actual type arguments. * / override def instantiateTypeParams(formals: List[Symbol], actuals: List[Type]) = { val annotations1 = annotations.map(info => AnnotationInfo(info.atp.instantiateTypeParams( - formals, actuals), info.args, info.assocs, info.pos)) + formals, actuals), info.args, info.assocs).setPos(info.pos)) val underlying1 = underlying.instantiateTypeParams(formals, actuals) if ((annotations1 eq annotations) && (underlying1 eq underlying)) this else AnnotatedType(annotations1, underlying1, selfsym) @@ -2790,7 +2790,7 @@ A type's typeSymbol should never be inspected directly. } def mapOver(annot: AnnotationInfo): Option[AnnotationInfo] = { - val AnnotationInfo(atp, args, assocs, pos) = annot + val AnnotationInfo(atp, args, assocs) = annot if (dropNonConstraintAnnotations && !(atp.typeSymbol isNonBottomSubClass TypeConstraintClass)) @@ -2803,7 +2803,7 @@ A type's typeSymbol should never be inspected directly. if ((args eq args1) && (atp eq atp1)) Some(annot) else if (args1.length == args.length) - Some(AnnotationInfo(atp1, args1, assocs, pos)) + Some(AnnotationInfo(atp1, args1, assocs).setPos(annot.pos)) else None } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 389de79d47..940a8e223b 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -778,7 +778,7 @@ abstract class ClassfileParser { this.hasMeta = true // Attribute on methods of java annotation classes when that method has a default case nme.AnnotationDefaultATTR => - sym.addAnnotation(AnnotationInfo(definitions.AnnotationDefaultAttr.tpe, List(), List(), NoPosition)) + sym.addAnnotation(AnnotationInfo(definitions.AnnotationDefaultAttr.tpe, List(), List())) in.skip(attrLen) // Java annotatinos on classes / methods / fields with RetentionPolicy.RUNTIME case nme.RuntimeAnnotationATTR => @@ -848,7 +848,7 @@ abstract class ClassfileParser { } } if (hasError) None - else Some(AnnotationInfo(attrType, List(), nvpairs.toList, NoPosition)) + else Some(AnnotationInfo(attrType, List(), nvpairs.toList)) } catch { case f: FatalError => throw f // don't eat fatal errors, they mean a class was not found case ex: Throwable => diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index bde47e480c..796ff4584a 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -459,7 +459,7 @@ abstract class Pickler extends SubComponent { putAnnotation(annInfo) } } - val AnnotationInfo(tpe, args, assocs, _) = annot + val AnnotationInfo(tpe, args, assocs) = annot putType(tpe) args foreach putAnnotArg assocs foreach { asc => @@ -605,7 +605,7 @@ abstract class Pickler extends SubComponent { } // annotations attached to a symbol (i.e. annots on terms) - case (target: Symbol, annot@AnnotationInfo(_, _, _, _)) => + case (target: Symbol, annot@AnnotationInfo(_, _, _)) => writeRef(target) writeAnnotation(annot) SYMANNOT @@ -957,7 +957,7 @@ abstract class Pickler extends SubComponent { MODIFIERS // annotations on types (not linked to a symbol) - case annot@AnnotationInfo(_, _, _, _) => + case annot@AnnotationInfo(_, _, _) => writeAnnotation(annot) ANNOTINFO @@ -1063,7 +1063,7 @@ abstract class Pickler extends SubComponent { printRef(tp) printRefs(annots) } - case (target: Symbol, AnnotationInfo(atp, args, Nil, _)) => + case (target: Symbol, AnnotationInfo(atp, args, Nil)) => print("SYMANNOT ") printRef(target) printRef(atp) @@ -1072,7 +1072,7 @@ abstract class Pickler extends SubComponent { print("CHILDREN ") printRef(target) for (c <- children) printRef(c.asInstanceOf[Symbol]) - case AnnotationInfo(atp, args, Nil, _) => + case AnnotationInfo(atp, args, Nil) => print("ANNOTINFO") printRef(atp) for (c <- args) printRef(c) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index 2edfbbe6ca..d9c64c6531 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -417,7 +417,7 @@ abstract class UnPickler { else args += at(argref, readAnnotArg) } - AnnotationInfo(atp, args.toList, assocs.toList, NoPosition) + AnnotationInfo(atp, args.toList, assocs.toList) } diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 2bbe419dab..8136893fcb 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -9,7 +9,7 @@ package transform import symtab._ import Flags._ -import scala.tools.nsc.util.{ Position, NoPosition } +import scala.tools.nsc.util.Position import scala.collection.mutable.{ListBuffer, HashMap} abstract class CleanUp extends Transform with ast.TreeDSL { @@ -32,10 +32,10 @@ abstract class CleanUp extends Transform with ast.TreeDSL { private var localTyper: analyzer.Typer = null private lazy val serializableAnnotation = - AnnotationInfo(SerializableAttr.tpe, Nil, Nil, NoPosition) + AnnotationInfo(SerializableAttr.tpe, Nil, Nil) private lazy val serialVersionUIDAnnotation = { val attr = definitions.getClass("scala.SerialVersionUID") - AnnotationInfo(attr.tpe, List(Literal(Constant(0))), List(), NoPosition) + AnnotationInfo(attr.tpe, List(Literal(Constant(0))), List()) } private object MethodDispatchType extends scala.Enumeration { diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 8133478c88..b6187204d8 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -611,7 +611,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { .setInfo(IntClass.tpe) .setFlag(PROTECTED) atPhase(currentRun.typerPhase) { - sym addAnnotation AnnotationInfo(VolatileAttr.tpe, Nil, Nil, NoPosition) + sym addAnnotation AnnotationInfo(VolatileAttr.tpe, Nil, Nil) } clazz.info.decls.enter(sym) addDef(clazz.pos, VAL(sym) === ZERO) diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index f2286ed679..91b6e1e9d3 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -271,7 +271,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { */ def concreteTypes(sym: Symbol): List[Type] = sym.getAnnotation(SpecializedClass) match { - case Some(AnnotationInfo(_, args, _, _)) => + case Some(AnnotationInfo(_, args, _)) => args match { case Literal(ct) :: _ => val tpes = parseTypes(ct.stringValue) diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 330c80bd4c..7360a9e07f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -8,7 +8,7 @@ package scala.tools.nsc package typechecker import scala.collection.mutable.HashMap -import scala.tools.nsc.util.{ Position, NoPosition } +import scala.tools.nsc.util.Position import symtab.Flags import symtab.Flags._ @@ -919,7 +919,7 @@ trait Namers { self: Analyzer => } else typer.typedType(tpt).tpe // #2382: return type of default getters are always @uncheckedVariance if (meth.hasFlag(DEFAULTPARAM)) - rt.withAnnotation(AnnotationInfo(definitions.uncheckedVarianceClass.tpe, List(), List(), NoPosition)) + rt.withAnnotation(AnnotationInfo(definitions.uncheckedVarianceClass.tpe, List(), List())) else rt }) } diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 9682726c81..e3d75752f2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -9,7 +9,6 @@ package typechecker import symtab.Flags import symtab.Flags._ -import util.NoPosition import scala.collection.mutable.ListBuffer /**