From 828377d9c0c86471a1c18ba11ff13460400729cf Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 2 Feb 2007 18:16:08 +0000 Subject: deprecated checks moved to refchecks. --- src/compiler/scala/tools/nsc/Global.scala | 6 ++-- .../scala/tools/nsc/ast/TreePrinters.scala | 2 +- .../scala/tools/nsc/ast/parser/Parsers.scala | 7 ++--- .../scala/tools/nsc/backend/jvm/GenJVM.scala | 29 +++++++++--------- .../scala/tools/nsc/backend/opt/Inliners.scala | 2 +- .../scala/tools/nsc/doc/DocGenerator.scala | 2 +- .../scala/tools/nsc/symtab/Definitions.scala | 4 +++ src/compiler/scala/tools/nsc/symtab/Symbols.scala | 10 +++---- .../nsc/symtab/classfile/ClassfileParser.scala | 6 ++-- .../tools/nsc/symtab/classfile/PickleFormat.scala | 2 +- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 31 +++++++++++--------- .../tools/nsc/symtab/classfile/UnPickler.scala | 34 ++++++++++++++++++++-- .../scala/tools/nsc/typechecker/Namers.scala | 2 +- .../scala/tools/nsc/typechecker/RefChecks.scala | 22 +++++++++++++- .../tools/nsc/typechecker/SyntheticMethods.scala | 2 +- .../scala/tools/nsc/typechecker/Typers.scala | 20 ------------- 16 files changed, 110 insertions(+), 71 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 49d94f5ff7..9a3f66483e 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -368,9 +368,9 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable mixer, cleanup, genicode, - inliner, - closureElimination, - deadCode, +// inliner, +// closureElimination, +// deadCode, genJVM, sampleTransform) diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index 3b3fca377c..b94fecddd3 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -108,7 +108,7 @@ abstract class TreePrinters { def attrInfoToString(attr: AttrInfo): String = { val str = new StringBuilder() attr match { - case Triple(tp, args, nvPairs) => + case AttrInfo(tp, args, nvPairs) => str.append(tp.toString()) if (!args.isEmpty) str.append(args.map(.escapedStringValue).mkString("(", ",", ")")) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 3290333d2d..7450aea91e 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1421,7 +1421,7 @@ trait Parsers requires SyntaxAnalyzer { mods | mod } - /** AccessQualifier ::= "[" Id | this "]" + /** AccessQualifier ::= "[" (Id | this) "]" */ def accessQualifierOpt(mods: Modifiers) = { var result = mods @@ -1440,8 +1440,8 @@ trait Parsers requires SyntaxAnalyzer { */ def accessModifierOpt(): Modifiers = normalize { in.token match { - case PRIVATE => accessQualifierOpt(Modifiers(Flags.PRIVATE)) - case PROTECTED => accessQualifierOpt(Modifiers(Flags.PROTECTED)) + case PRIVATE => in.nextToken(); accessQualifierOpt(Modifiers(Flags.PRIVATE)) + case PROTECTED => in.nextToken(); accessQualifierOpt(Modifiers(Flags.PROTECTED)) case _ => NoMods } } @@ -1450,7 +1450,6 @@ trait Parsers requires SyntaxAnalyzer { * Modifier ::= LocalModifier * | AccessModifier * | override - * | (private | protected) [ "[" Id | this "]" ] */ def modifiers(): Modifiers = normalize { def loop(mods: Modifiers): Modifiers = in.token match { diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 433f4f055a..3ada583b2c 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -148,13 +148,13 @@ abstract class GenJVM extends SubComponent { if (!forCLDC) for (val attr <- c.symbol.attributes) attr match { - case Triple(SerializableAttr, _, _) => + case AttrInfo(SerializableAttr, _, _) => parents = parents ::: List(definitions.SerializableClass.tpe) - case Triple(CloneableAttr, _, _) => + case AttrInfo(CloneableAttr, _, _) => parents = parents ::: List(CloneableClass.tpe) - case Triple(SerialVersionUID, value :: _, _) => + case AttrInfo(SerialVersionUID, value :: _, _) => serialVUID = Some(value.longValue) - case Triple(RemoteAttr, _, _) => + case AttrInfo(RemoteAttr, _, _) => parents = parents ::: List(RemoteInterface.tpe) remoteClass = true case _ => () @@ -203,7 +203,7 @@ abstract class GenJVM extends SubComponent { def addExceptionsAttribute(sym: Symbol): Unit = { val Pair(excs, others) = sym.attributes.partition((a => a match { - case Triple(ThrowsAttr, _, _) => true + case AttrInfo(ThrowsAttr, _, _) => true case _ => false })) if (excs isEmpty) return; @@ -216,7 +216,7 @@ abstract class GenJVM extends SubComponent { // put some radom value; the actual number is determined at the end buf.putShort(0xbaba.toShort) - for (val Triple(ThrowsAttr, List(exc), _) <- excs.removeDuplicates) { + for (val AttrInfo(ThrowsAttr, List(exc), _) <- excs.removeDuplicates) { buf.putShort(cpool.addClass(exc.typeValue.toString()).shortValue) nattr = nattr + 1 } @@ -277,7 +277,8 @@ abstract class GenJVM extends SubComponent { // put some radom value; the actual number of annotations is determined at the end buf.putShort(0xbaba.toShort) - for (val Triple(typ, consts, nvPairs) <- attributes; typ.symbol.hasFlag(Flags.JAVA)) { + for (val AttrInfo(typ, consts, nvPairs) <- attributes; + typ.symbol isNonBottomSubClass definitions.ClassfileAttributeClass) { nattr = nattr + 1 val jtype = javaType(typ) buf.putShort(cpool.addUtf8(jtype.getSignature()).toShort) @@ -310,8 +311,8 @@ abstract class GenJVM extends SubComponent { def addParamAnnotations(pattrss: List[List[AttrInfo]]): Unit = { val attributes = for (val attrs <- pattrss) yield - for (val attr @ Triple(tpe, _, _) <- attrs; - tpe.symbol hasFlag Flags.JAVA) yield attr; + for (val attr @ AttrInfo(tpe, _, _) <- attrs; + tpe.symbol isNonBottomSubClass definitions.ClassfileAttributeClass) yield attr; if (attributes.forall(.isEmpty)) return; val buf: ByteBuffer = ByteBuffer.allocate(2048) @@ -369,9 +370,9 @@ abstract class GenJVM extends SubComponent { var attributes = 0 f.symbol.attributes foreach { a => a match { - case Triple(TransientAtt, _, _) => + case AttrInfo(TransientAtt, _, _) => attributes = attributes | JAccessFlags.ACC_TRANSIENT - case Triple(VolatileAttr, _, _) => + case AttrInfo(VolatileAttr, _, _) => attributes = attributes | JAccessFlags.ACC_VOLATILE case _ => (); }} @@ -410,11 +411,11 @@ abstract class GenJVM extends SubComponent { jmethod.addAttribute(fjbgContext.JOtherAttribute(jclass, jmethod, "Bridge", new Array[Byte](0))) if ((remoteClass || - (m.symbol.attributes contains Triple(RemoteAttr, Nil, Nil))) && + (m.symbol.attributes contains AttrInfo(RemoteAttr, Nil, Nil))) && jmethod.isPublic() && !forCLDC) { m.symbol.attributes = - Triple(ThrowsAttr, List(Constant(RemoteException)), List()) :: m.symbol.attributes; + AttrInfo(ThrowsAttr, List(Constant(RemoteException)), List()) :: m.symbol.attributes; } if (!jmethod.isAbstract()) { @@ -1342,7 +1343,7 @@ abstract class GenJVM extends SubComponent { def needsInterfaceCall(sym: Symbol): Boolean = sym.hasFlag(Flags.INTERFACE) || (sym.hasFlag(Flags.JAVA) && - sym.isNonBottomSubClass(definitions.AttributeClass)) + sym.isNonBottomSubClass(definitions.ClassfileAttributeClass)) def javaType(t: TypeKind): JType = t match { diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index 377c073f5f..d32ab4a87c 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -266,7 +266,7 @@ abstract class Inliners extends SubComponent { if ( classes.contains(receiver) && (isClosureClass(receiver) || concreteMethod.isFinal - || msym.attributes.exists(a => a._1 == InlineAttr))) { + || msym.attributes.exists(a => a.atp == InlineAttr))) { classes(receiver).lookupMethod(concreteMethod) match { case Some(inc) => if (inc != m && (inc.code ne null) diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala index 0754ef6397..6b509a44de 100644 --- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala @@ -316,7 +316,7 @@ abstract class DocGenerator extends Models { else { def attrFor(attr: AttrInfo): Node = { val buf = new StringBuilder - val Triple(tpe, args, nvPairs) = attr + val AttrInfo(tpe, args, nvPairs) = attr val name = aref(urlFor(tpe.symbol), contentFrame, tpe.toString) if (!args.isEmpty) buf.append(args.map(.escapedStringValue).mkString("(", ",", ")")) diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 9d45255ad0..0b05696ee2 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -59,6 +59,8 @@ trait Definitions requires SymbolTable { var ScalaObjectClass: Symbol = _ def ScalaObjectClass_tag = getMember(ScalaObjectClass, nme.tag) var AttributeClass: Symbol = _ + var ClassfileAttributeClass: Symbol = _ + var StaticAttributeClass: Symbol = _ //var ChannelClass: Symbol = _ // def Channel_send = getMember(ChannelClass, nme.send) // def Channel_receive = getMember(ChannelClass, nme.receive) @@ -698,6 +700,8 @@ trait Definitions requires SymbolTable { // the scala reference classes ScalaObjectClass = getClass("scala.ScalaObject") AttributeClass = getClass("scala.Attribute") + ClassfileAttributeClass = getClass("scala.ClassfileAttribute") + StaticAttributeClass = getClass("scala.StaticAttribute") //ChannelClass = getClass("scala.distributed.Channel") //RemoteRefClass = getClass("scala.distributed.RemoteRef") if (!forCLDC) { diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 76f50c1120..a586f7c026 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -20,8 +20,6 @@ trait Symbols requires SymbolTable { var typeSymbolCount = 0 var classSymbolCount = 0 - type AttrInfo = Triple[Type, List[Constant], List[Pair[Name,Constant]]] - val emptySymbolArray = new Array[Symbol](0) val emptySymbolSet = Set.empty[Symbol] type PositionType; @@ -153,7 +151,7 @@ trait Symbols requires SymbolTable { final def newAnonymousFunctionClass(pos: PositionType) = { val anonfun = newClass(pos, nme.ANON_FUN_NAME.toTypeName) anonfun.attributes = - Triple(definitions.SerializableAttr.tpe, List(), List()) :: anonfun.attributes + AttrInfo(definitions.SerializableAttr.tpe, List(), List()) :: anonfun.attributes anonfun } final def newRefinementClass(pos: PositionType) = @@ -211,7 +209,7 @@ trait Symbols requires SymbolTable { final def isEmptyPackage = isPackage && name == nme.EMPTY_PACKAGE_NAME final def isEmptyPackageClass = isPackageClass && name == nme.EMPTY_PACKAGE_NAME.toTypeName def isDeprecated = - attributes exists (attr => attr._1.symbol == DeprecatedAttr) + attributes exists (attr => attr.atp.symbol == DeprecatedAttr) /** Does this symbol denote a wrapper object of the interpreter or its class? */ final def isInterpreterWrapper = @@ -535,7 +533,7 @@ trait Symbols requires SymbolTable { } def getAttributes(clazz: Symbol): List[AttrInfo] = - attributes.filter(._1.symbol.isNonBottomSubClass(clazz)) + attributes.filter(.atp.symbol.isNonBottomSubClass(clazz)) /** Reset symbol to initial state */ @@ -1308,6 +1306,8 @@ trait Symbols requires SymbolTable { def cloneSymbolImpl(owner: Symbol): Symbol = throw new Error() } + case class AttrInfo(atp: Type, args: List[Constant], assocs: List[{Name, Constant}]) + def cloneSymbols(syms: List[Symbol]): List[Symbol] = { val syms1 = syms map (.cloneSymbol) for (val sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1)) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index bc348962b6..c0850ddb0a 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -362,7 +362,7 @@ abstract class ClassfileParser { val c = pool.getClassSymbol(in.nextChar) if (c != clazz) throw new IOException("class file '" + in.file + "' contains wrong " + c) - val superType = if (isAttribute) { in.nextChar; definitions.AttributeClass.tpe } + val superType = if (isAttribute) { in.nextChar; definitions.ClassfileAttributeClass.tpe } else pool.getSuperClass(in.nextChar).tpe val ifaceCount = in.nextChar val parents = (superType :: @@ -651,7 +651,7 @@ abstract class ClassfileParser { } case nme.AnnotationDefaultATTR => sym.attributes = - Triple(definitions.AnnotationDefaultAttr.tpe, List(), List()) :: sym.attributes + AttrInfo(definitions.AnnotationDefaultAttr.tpe, List(), List()) :: sym.attributes in.skip(attrLen) case nme.RuntimeAnnotationATTR => parseAnnotations(attrLen) @@ -702,7 +702,7 @@ abstract class ClassfileParser { val name = pool.getName(in.nextChar) nvpairs += Pair(name, parseTaggedConstant()) } - sym.attributes = Triple(attrType, List(), nvpairs.toList) :: sym.attributes + sym.attributes = AttrInfo(attrType, List(), nvpairs.toList) :: sym.attributes } } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala b/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala index f72089c991..e31b29eaf6 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/PickleFormat.scala @@ -50,7 +50,7 @@ object PickleFormat { * | 33 LITERALstring len_Nat name_Ref * | 34 LITERALnull len_Nat * | 35 LITERALclass len_Nat type_Ref - * | 40 ATTRIBUTE sym_Ref type_Ref {constant_Ref} + * | 40 ATTRIBUTE len_Nat sym_Ref info_Ref {constant_Ref} {nameRef constantRef} * | 72 PosTYPEsym len_Nat pos_Nat SymbolInfo * | 73 PosALIASsym len_Nat pos_Nat SymbolInfo * | 74 PosCLASSsym len_Nat pos_Nat SymbolInfo [thistype_Ref] diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 857f9b9db2..a0cf082760 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -109,7 +109,10 @@ abstract class Pickler extends SubComponent { putType(sym.typeOfThis); putSymbol(sym.alias) - //for (val attr <- sym.attributes) putAttribute(sym, attr); + for (val attr <- sym.attributes.reverse) { + if (attr.atp.symbol isNonBottomSubClass definitions.StaticAttributeClass) + putAttribute(sym, attr) + } } else if (sym != NoSymbol) { putEntry(if (sym.isModuleClass) sym.name.toTermName else sym.name) if (!sym.owner.isRoot) putSymbol(sym.owner) @@ -162,12 +165,14 @@ abstract class Pickler extends SubComponent { if (c.tag == StringTag) putEntry(newTermName(c.stringValue)) else if (c.tag == ClassTag) putEntry(c.typeValue) } -/* - private def putAttribute(attr: AttrInfo): unit = if (putEntry(attr)) { - putType(attr._1); - for (val c <- attr._2) putConstant(c); + + private def putAttribute(sym: Symbol, attr: AttrInfo): unit = { + assert(putEntry({sym, attr})) + putType(attr.atp) + for (val c <- attr.args) putConstant(c) + for (val {name, c} <- attr.assocs) { putEntry(name); putConstant(c) } } -*/ + // Phase 2 methods: Write all entries to byte array ------------------------------ private val buf = new PickleBuffer(new Array[byte](4096), -1, 0) @@ -265,14 +270,14 @@ abstract class Pickler extends SubComponent { else if (c.tag == StringTag) writeRef(newTermName(c.stringValue)) else if (c.tag == ClassTag) writeRef(c.typeValue) LITERAL + c.tag -/* - case Pair(tp, cs) => - writeRef(tp); - for (val c <- cs) writeRef(cs); + case {target: Symbol, attr @ AttrInfo(atp, args, assocs)} => + writeRef(target) + writeRef(atp) + for (val c <- args) writeRef(c) + for (val {name, c} <- assocs) { writeRef(name); writeRef(c) } ATTRIBUTE -*/ - case AttributedType(attribs, tp) - => writeBody(tp) // obviously, this should be improved + case AttributedType(attribs, tp) => + writeBody(tp) // obviously, this should be improved case _ => throw new FatalError("bad entry: " + entry + " " + entry.getClass())//debug } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index 4aa93590c4..951b96c84f 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -12,7 +12,7 @@ import java.lang.{Float, Double} import Flags._ import PickleFormat._ -import collection.mutable.HashMap +import collection.mutable.{HashMap, ListBuffer} import java.io.IOException /** This abstract class implements .. @@ -47,7 +47,8 @@ abstract class UnPickler { private val symScopes = new HashMap[Symbol, Scope] for (val i <- 0 until index.length) { - if (isSymbolEntry(i)) { at(i, readSymbol); () } + if (isSymbolEntry(i)) { at(i, readSymbol); {} } + else if (isAttributeEntry(i)) { at(i, readAttribute); {} } } if (settings.debug.value) global.log("unpickled " + classRoot + ":" + classRoot.rawInfo + ", " + moduleRoot + ":" + moduleRoot.rawInfo);//debug @@ -80,6 +81,17 @@ abstract class UnPickler { val tag = bytes(index(i)) % PosOffset (firstSymTag <= tag && tag <= lastExtSymTag) } + + /** Does entry represent a name? */ + private def isNameEntry(i: int): boolean = { + val tag = bytes(index(i)) + tag == TERMname || tag == TYPEname + } + + /** Does entry represent a symbol attribute? */ + private def isAttributeEntry(i: int): boolean = + bytes(index(i)) == ATTRIBUTE + /** Does entry represent a refinement symbol? * pre: Entry is a class symbol */ @@ -266,6 +278,24 @@ abstract class UnPickler { } } + /** Read an attribute and store in referenced symbol */ + private def readAttribute(): AttrInfo = { + val tag = readByte() + val end = readNat() + readIndex + val target = readSymbolRef() + val attrType = readTypeRef() + val args = new ListBuffer[Constant] + val assocs = new ListBuffer[{Name, Constant}] + while (readIndex != end) { + val argref = readNat() + if (isNameEntry(argref)) assocs += {at(argref, readName), readConstantRef()} + else args += at(argref, readConstant) + } + val attr = AttrInfo(attrType, args.toList, assocs.toList) + target.attributes = attr :: target.attributes + attr + } + /** Read a reference to a name, symbol, type or constant */ private def readNameRef(): Name = at(readNat(), readName) private def readSymbolRef(): Symbol = at(readNat(), readSymbol) diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index eb803266e0..2bc9023485 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -696,7 +696,7 @@ trait Namers requires Analyzer { 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") } - Triple(tpt.tpe, constrArgs, nvPairs) + AttrInfo(tpt.tpe, constrArgs, nvPairs) } } if (!attrError) { diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 8209665c15..706f16a5ad 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -555,6 +555,24 @@ abstract class RefChecks extends InfoTransform { result } + /** Check that a deprecated val or def does not override a + * concrete, non-deprecated method. If it does, then + * deprecation is meaningless. + */ + def checkDeprecatedOvers() { + val symbol = tree.symbol + if (symbol.isDeprecated) { + val concrOvers = + symbol.allOverriddenSymbols.filter(sym => + !sym.isDeprecated && !(sym hasFlag DEFERRED)) + if(!concrOvers.isEmpty) + unit.deprecationWarning( + tree.pos, + symbol.toString + " overrides concrete, non-deprecated symbol(s):" + + concrOvers.map(.fullNameString).mkString(" ", ", ", "")) + } + } + val savedLocalTyper = localTyper val sym = tree.symbol var result = tree @@ -565,9 +583,11 @@ abstract class RefChecks extends InfoTransform { case DefDef(_, _, _, _, _, _) => validateVariance(sym, sym.tpe, CoVariance) + checkDeprecatedOvers() case ValDef(_, _, _, _) => - validateVariance(sym, sym.tpe, if (sym.isVariable) NoVariance else CoVariance); + validateVariance(sym, sym.tpe, if (sym.isVariable) NoVariance else CoVariance) + checkDeprecatedOvers() case AbsTypeDef(_, _, _, _) => validateVariance(sym, sym.info, CoVariance) diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 5d0eb63925..bb410170bd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -210,7 +210,7 @@ trait SyntheticMethods requires Analyzer { if (clazz hasFlag CASE) { // case classes are implicitly declared serializable - clazz.attributes = Triple(SerializableAttr.tpe, List(), List()) :: clazz.attributes + clazz.attributes = AttrInfo(SerializableAttr.tpe, List(), List()) :: clazz.attributes for (val stat <- templ.body) { if (stat.isDef && stat.symbol.isMethod && stat.symbol.hasFlag(CASEACCESSOR) && !isPublic(stat.symbol)) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 36b9fef394..3d6bc33c02 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -931,7 +931,6 @@ trait Typers requires Analyzer { } else { newTyper(context.make(vdef, sym)).transformedOrTyped(vdef.rhs, tpt1.tpe) } - checkDeprecatedOvers(vdef) copy.ValDef(vdef, vdef.mods, vdef.name, tpt1, rhs1) setType NoType } @@ -998,24 +997,6 @@ trait Typers requires Analyzer { } } - /** Check that a deprecated val or def does not override a - * concrete, non-deprecated method. If it does, then - * deprecation is meaningless. - */ - def checkDeprecatedOvers(tree: Tree): Unit = { - if(!phase.erasedTypes ) return () - val symbol = tree.symbol - if(!symbol.isDeprecated) return () - val concrOvers = - symbol.allOverriddenSymbols.filter(sym => - !sym.isDeprecated && !(sym hasFlag DEFERRED)) - if(!concrOvers.isEmpty) - unit.deprecationWarning( - tree.pos, - symbol.toString + " overrides concrete, non-deprecated symbol(s):" + - concrOvers.map(.fullNameString).mkString(" ", ", ", "")) - } - /** * @param ddef ... * @return ... @@ -1077,7 +1058,6 @@ trait Typers requires Analyzer { computeParamAliases(meth.owner, vparamss1, result) result } else transformedOrTyped(ddef.rhs, tpt1.tpe) - checkDeprecatedOvers(ddef) copy.DefDef(ddef, ddef.mods, ddef.name, tparams1, vparamss1, tpt1, rhs1) setType NoType } -- cgit v1.2.3