Skip to content

Commit e3005f0

Browse files
committed
Honor strict unused warnings
1 parent 38c0a1e commit e3005f0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
171171
tree
172172

173173
override def prepareForDefDef(tree: DefDef)(using Context): Context =
174-
def trivial = tree.symbol.is(Deferred) || isUnconsuming(tree.rhs)
174+
def fewerUnused = ctx.settings.Yunused.value != "strict"
175+
def trivial = tree.symbol.is(Deferred) || fewerUnused && isUnconsuming(tree.rhs)
175176
def nontrivial = tree.symbol.isConstructor || tree.symbol.isAnonymousFunction
176177
if !nontrivial && trivial then
177178
refInfos.skip.addOne(tree.symbol)

tests/warn/i22742b.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
//> using options -Wunused:all -Yunused:strict
3+
4+
def f(x: Int) = () // warn strict means warn in obviously trivial definitions

0 commit comments

Comments
 (0)