diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-10-19 12:09:40 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2017-03-11 23:48:31 -0800 |
commit | 833724b131f86b978f0831f637d386d7ca37a2aa (patch) | |
tree | 2033b6e43ab889e8fad2518b75cfce23adde4855 /src/compiler/scala/tools | |
parent | a85521efbbf65161debc460ab5cb55562db051e9 (diff) | |
download | scala-833724b131f86b978f0831f637d386d7ca37a2aa.tar.gz scala-833724b131f86b978f0831f637d386d7ca37a2aa.tar.bz2 scala-833724b131f86b978f0831f637d386d7ca37a2aa.zip |
SI-7860 No warn private implicit value class
Previously, warned on unused synthetic companion.
Also avoid false negative via hashcode reference
to the underlying value.
Avoid the synthetic conversion method for the
implicit class (whose RHS always uses the class);
the def itself is synthetic so is normally not
warned.
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index ee2d00900a..b30972f931 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -355,7 +355,10 @@ trait TypeDiagnostics { // functions to manipulate the name def preQualify() = modifyName(trueOwner.fullName + "." + _) - def postQualify() = if (!(postQualifiedWith contains trueOwner)) { postQualifiedWith ::= trueOwner; modifyName(_ + "(in " + trueOwner + ")") } + def postQualify() = if (!(postQualifiedWith contains trueOwner)) { + postQualifiedWith ::= trueOwner + modifyName(s => s"$s(in $trueOwner)") + } def typeQualify() = if (sym.isTypeParameterOrSkolem) postQualify() def nameQualify() = if (trueOwner.isPackageClass) preQualify() else postQualify() @@ -498,11 +501,13 @@ trait TypeDiagnostics { override def traverse(t: Tree): Unit = { t match { - case m: MemberDef if qualifies(t.symbol) => defnTrees += m + case m: MemberDef if qualifies(t.symbol) => + defnTrees += m t match { case DefDef(mods@_, name@_, tparams@_, vparamss, tpt@_, rhs@_) if !t.symbol.isAbstract && !t.symbol.isDeprecated => if (t.symbol.isPrimaryConstructor) for (cpa <- t.symbol.owner.constrParamAccessors if cpa.isPrivateLocal) params += cpa + else if (t.symbol.isSynthetic && t.symbol.isImplicit) return else if (!t.symbol.isConstructor) for (vs <- vparamss) params ++= vs.map(_.symbol) case _ => @@ -525,6 +530,7 @@ trait TypeDiagnostics { case NoType | NoPrefix => case NullaryMethodType(_) => case MethodType(_, _) => + case SingleType(_, _) => case _ => log(s"$tp referenced from $currentOwner") treeTypes += tp @@ -547,6 +553,7 @@ trait TypeDiagnostics { def isSyntheticWarnable(sym: Symbol) = ( sym.isDefaultGetter ) + def isUnusedTerm(m: Symbol): Boolean = ( (m.isTerm) && (!m.isSynthetic || isSyntheticWarnable(m)) @@ -562,7 +569,7 @@ trait TypeDiagnostics { def treepos(t: Tree): Int = if (t.pos.isDefined) t.pos.point else sympos(t.symbol) - def unusedTypes = defnTrees.toList filter (t => isUnusedType(t.symbol)) sortBy treepos + def unusedTypes = defnTrees.toList.filter(t => isUnusedType(t.symbol)).sortBy(treepos) def unusedTerms = { val all = defnTrees.toList.filter(v => isUnusedTerm(v.symbol)) |