From d0ff0907e0cef7cd8defba12416e902e49e9f9e6 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 10 Dec 2016 13:47:34 -0800 Subject: SI-8040 Avoid Null companion Don't warn on the private constructor of an abstract class. Instead, take it as a signal that the class must not be instantiated. --- src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index b30972f931..042c58226a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -557,7 +557,7 @@ trait TypeDiagnostics { def isUnusedTerm(m: Symbol): Boolean = ( (m.isTerm) && (!m.isSynthetic || isSyntheticWarnable(m)) - && (m.isPrivate || m.isLocalToBlock) + && ((m.isPrivate && !(m.isConstructor && m.owner.isAbstract))|| m.isLocalToBlock) && !targets(m) && !(m.name == nme.WILDCARD) // e.g. val _ = foo && (m.isValueParameter || !ignoreNames(m.name.toTermName)) // serialization methods @@ -594,7 +594,7 @@ trait TypeDiagnostics { def apply(unit: CompilationUnit): Unit = if (warningsEnabled) { val p = new UnusedPrivates - p traverse unit.body + p.traverse(unit.body) if (settings.warnUnusedLocals || settings.warnUnusedPrivates) { for (defn: DefTree <- p.unusedTerms) { val sym = defn.symbol -- cgit v1.2.3