Skip to content

Commit

Permalink
Merge pull request #10154 from som-snytt/issue/12646-unused-local
Browse files Browse the repository at this point in the history
Avoid warning on setter in trait
  • Loading branch information
lrytz committed Sep 26, 2022
2 parents fed3c2b + 8b7eedf commit 8f57a00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -547,7 +547,7 @@ trait TypeDiagnostics extends splain.SplainDiagnostics {
if (sym.isPrimaryConstructor)
for (cpa <- sym.owner.constrParamAccessors if cpa.isPrivateLocal) params += cpa
else if (sym.isSynthetic && sym.isImplicit) return
else if (!sym.isConstructor && !isTrivial(rhs))
else if (!sym.isConstructor && !sym.isVar && !isTrivial(rhs))
for (vs <- vparamss) params ++= vs.map(_.symbol)
defnTrees += m
case _ =>
Expand Down
11 changes: 11 additions & 0 deletions test/files/pos/t12646.scala
@@ -0,0 +1,11 @@

// scalac: -Werror -Wunused:params

trait T {
private var x: String = _

def y: String = {
if (x eq null) x = "hello, world"
x
}
}

0 comments on commit 8f57a00

Please sign in to comment.