Skip to content

Commit 307ef10

Browse files
committed
Fix WUnused false positive in for
1 parent d640193 commit 307ef10

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ object CheckUnused:
467467
if ctx.settings.WunusedHas.explicits then
468468
explicitParamInScope
469469
.filterNot(d => d.symbol.usedDefContains)
470+
.filterNot(d => usedInPosition.exists { case (pos, name) => d.span.contains(pos.span) && name == d.symbol.name})
470471
.map(d => d.namePos -> WarnTypes.ExplicitParams).toList
471472
else
472473
Nil

tests/neg-custom-args/fatal-warnings/i15503i.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,13 @@ package foo.test.i16679b:
245245
import Foo.x
246246
case class CoolClass(i: Int)
247247
println(summon[myPackage.CaseClassName[CoolClass]])
248+
249+
package foo.test.i17175:
250+
val continue = true
251+
def foo =
252+
for {
253+
i <- 1.until(10) // OK
254+
if continue
255+
} {
256+
println(i)
257+
}

0 commit comments

Comments
 (0)