summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-06-10 12:32:06 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-07-04 15:49:07 +0200
commite08735380e8cba8f4b7230f5615e528782a0111a (patch)
treec1719135c315a32db4f921aebbb6d6e0f56eb0a8 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent62c8f90f3105b8f19a9f29f104ff232438372c73 (diff)
downloadscala-e08735380e8cba8f4b7230f5615e528782a0111a.tar.gz
scala-e08735380e8cba8f4b7230f5615e528782a0111a.tar.bz2
scala-e08735380e8cba8f4b7230f5615e528782a0111a.zip
Track symbol that caused a deprecation warning.
So that we can filter deprecations based on defining package. Configurable error reporting will support a rule like: "In compilation unit X, escalate deprecation warnings that result from accessing members in package P that have been deprecated since version V. Report an error instead of a warning for those." TODO: remove deprecationWarning overload that doesn't take a `Symbol`? (Replace by a default value of `NoSymbol` for the deprecated symbol arg?)
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 059b58c943..3c215ea10b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -941,10 +941,9 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
def adaptConstant(value: Constant): Tree = {
val sym = tree.symbol
- if (sym != null && sym.isDeprecated) {
- val msg = sym.toString + sym.locationString + " is deprecated: " + sym.deprecationMessage.getOrElse("")
- unit.deprecationWarning(tree.pos, msg)
- }
+ if (sym != null && sym.isDeprecated)
+ unit.deprecationWarning(tree.pos, sym, s"${sym.toString}${sym.locationString} is deprecated: ${sym.deprecationMessage.getOrElse("")}")
+
treeCopy.Literal(tree, value)
}
@@ -1676,7 +1675,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (!isPastTyper && psym.hasDeprecatedInheritanceAnnotation && !sameSourceFile) {
val suffix = psym.deprecatedInheritanceMessage map (": " + _) getOrElse ""
val msg = s"inheritance from ${psym.fullLocationString} is deprecated$suffix"
- unit.deprecationWarning(parent.pos, msg)
+ unit.deprecationWarning(parent.pos, psym, msg)
}
if (psym.isSealed && !phase.erasedTypes)
@@ -3666,7 +3665,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
if (annType.typeSymbol == DeprecatedAttr && argss.flatten.size < 2)
- unit.deprecationWarning(ann.pos, "@deprecated now takes two arguments; see the scaladoc.")
+ unit.deprecationWarning(ann.pos, DeprecatedAttr, "@deprecated now takes two arguments; see the scaladoc.")
if ((typedAnn.tpe == null) || typedAnn.tpe.isErroneous) ErroneousAnnotation
else annInfo(typedAnn)
@@ -4698,10 +4697,10 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
// temporarily use `filter` as an alternative for `withFilter`
def tryWithFilterAndFilter(tree: Select, qual: Tree): Tree = {
- def warn() = unit.deprecationWarning(tree.pos, s"`withFilter' method does not yet exist on ${qual.tpe.widen}, using `filter' method instead")
+ def warn(sym: Symbol) = unit.deprecationWarning(tree.pos, sym, s"`withFilter' method does not yet exist on ${qual.tpe.widen}, using `filter' method instead")
silent(_ => typedSelect(tree, qual, nme.withFilter)) orElse { _ =>
silent(_ => typed1(Select(qual, nme.filter) setPos tree.pos, mode, pt)) match {
- case SilentResultValue(res) => warn() ; res
+ case SilentResultValue(res) => warn(res.symbol) ; res
case SilentTypeError(err) => WithFilterError(tree, err)
}
}
@@ -5482,7 +5481,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
def reportWarning(inferredType: Type) = {
val explanation = s"inference of $inferredType from macro impl's c.Expr[$inferredType] is deprecated and is going to stop working in 2.12"
- unit.deprecationWarning(ddef.pos, s"$commonMessage ($explanation)")
+ unit.deprecationWarning(ddef.pos, ddef.symbol, s"$commonMessage ($explanation)")
}
computeMacroDefTypeFromMacroImplRef(ddef, rhs1) match {
case ErrorType => ErrorType