diff options
author | Som Snytt <som.snytt@gmail.com> | 2017-04-06 18:13:22 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2017-04-06 18:13:22 -0700 |
commit | bad61ce0ff9f460c2f8873c134a7f6bee0a53824 (patch) | |
tree | a8f4cba306966ce23a0ec6629f6e355f76a584cf | |
parent | 1290fff26ea626f5d1f9f3c65bd5bd0a97939332 (diff) | |
download | scala-bad61ce0ff9f460c2f8873c134a7f6bee0a53824.tar.gz scala-bad61ce0ff9f460c2f8873c134a7f6bee0a53824.tar.bz2 scala-bad61ce0ff9f460c2f8873c134a7f6bee0a53824.zip |
SD-363 Xlint no warn deprecated params, defaults
Deprecation is an escape hatch for unused params.
Since default arg getters receive values of previous
args, don't warn when they are unused.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala | 14 | ||||
-rw-r--r-- | test/files/pos/t8040.scala | 5 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 7013c7da93..a0139937f1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -567,10 +567,16 @@ trait TypeDiagnostics { && !treeTypes.exists(_ contains m) // e.g. val a = new Foo ; new a.Bar //&& !(m.isVal && m.info.resultType =:= typeOf[Unit]) // Unit val is uninteresting ) - def isUnusedParam(m: Symbol): Boolean = isUnusedTerm(m) && !(m.isParamAccessor && ( - m.owner.isImplicit || - targets.exists(s => s.isParameter && s.name == m.name && s.owner.isConstructor && s.owner.owner == m.owner) // exclude ctor params - )) + def isUnusedParam(m: Symbol): Boolean = ( + isUnusedTerm(m) + && !m.isDeprecated + && !m.owner.isDefaultGetter + && !(m.isParamAccessor && ( + m.owner.isImplicit || + targets.exists(s => s.isParameter + && s.name == m.name && s.owner.isConstructor && s.owner.owner == m.owner) // exclude ctor params + )) + ) def sympos(s: Symbol): Int = if (s.pos.isDefined) s.pos.point else if (s.isTerm) s.asTerm.referenced.pos.point else -1 def treepos(t: Tree): Int = diff --git a/test/files/pos/t8040.scala b/test/files/pos/t8040.scala index 1d1a770060..3e01014ab4 100644 --- a/test/files/pos/t8040.scala +++ b/test/files/pos/t8040.scala @@ -5,4 +5,9 @@ object Test { } def f(implicit x: DummyImplicit) = 42 // no warn DummyImplicit + + + def f(x: Int)(y: Int = 1) = x + y // no warn default getter + + def g(@deprecated("","") x: Int) = 42 // no warn deprecated } |