From 4cc8ccb5f3f79edc02c5c769253620c1f2ce436e Mon Sep 17 00:00:00 2001 From: Lex Spoon Date: Tue, 23 Jan 2007 13:46:50 +0000 Subject: Add a deprecation check for deprecated methods ... Add a deprecation check for deprecated methods overriding concrete methods. --- src/compiler/scala/tools/nsc/symtab/Symbols.scala | 2 ++ .../scala/tools/nsc/typechecker/Typers.scala | 27 ++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index c5892b79fb..dab6870aeb 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -209,6 +209,8 @@ trait Symbols requires SymbolTable { final def isRootPackage = isPackage && name == nme.ROOTPKG 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) /** Does this symbol denote a wrapper object of the interpreter or its class? */ final def isInterpreterWrapper = diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index b964c73297..89bab81fd8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -424,15 +424,14 @@ trait Typers requires Analyzer { * */ private def stabilize(tree: Tree, pre: Type, mode: int, pt: Type): Tree = { - def isDeprecated(sym: Symbol) = - sym.attributes exists (attr => attr._1.symbol == DeprecatedAttr) + def isDeprecated(sym: Symbol) = sym.isDeprecated if (tree.symbol.hasFlag(OVERLOADED) && (mode & FUNmode) == 0) inferExprAlternative(tree, pt) val sym = tree.symbol if (!phase.erasedTypes && isDeprecated(sym) && !context.owner.ownerChain.exists(isDeprecated)) { unit.deprecationWarning(tree.pos, - sym+sym.locationString+" is deprecated;\n see API documentation for alternatives") + sym+sym.locationString+" is deprecated") } if (tree.tpe.isError) tree else if ((mode & (PATTERNmode | FUNmode)) == PATTERNmode && tree.isTerm) { // (1) @@ -758,7 +757,7 @@ trait Typers requires Analyzer { /**

Check that

*