Skip to content

Commit fd7b962

Browse files
szymon-rdKordyjan
authored andcommitted
Do not register used symbol when position doesnt exist in wunused
1 parent 2a2a111 commit fd7b962

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ object CheckUnused:
358358
usedInScope.top += ((sym, sym.isAccessibleAsIdent, name, isDerived))
359359
usedInScope.top += ((sym.companionModule, sym.isAccessibleAsIdent, name, isDerived))
360360
usedInScope.top += ((sym.companionClass, sym.isAccessibleAsIdent, name, isDerived))
361-
name.map(n => usedInPosition += ((sym.sourcePos, n)))
361+
if sym.sourcePos.exists then
362+
name.map(n => usedInPosition += ((sym.sourcePos, n)))
362363

363364
/** Register a symbol that should be ignored */
364365
def addIgnoredUsage(sym: Symbol)(using Context): Unit =

tests/neg-custom-args/fatal-warnings/i15503-scala2/scala2-t11681.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Revaluing(u: Int) { def f = u } // OK
6060

6161
case class CaseyKasem(k: Int) // OK
6262

63-
case class CaseyAtTheBat(k: Int)(s: String) // error
63+
case class CaseyAtTheBat(k: Int)(s: String) // ok
6464

6565
trait Ignorance {
6666
def f(readResolve: Int) = answer // error

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ package foo.test.possibleclasses:
9090
k: Int, // OK
9191
private val y: Int // OK /* Kept as it can be taken from pattern */
9292
)(
93-
s: Int, // error /* But not these */
93+
s: Int,
9494
val t: Int, // OK
9595
private val z: Int // error
9696
)
@@ -131,7 +131,7 @@ package foo.test.possibleclasses.withvar:
131131
k: Int, // OK
132132
private var y: Int // OK /* Kept as it can be taken from pattern */
133133
)(
134-
s: Int, // error /* But not these */
134+
s: Int,
135135
var t: Int, // OK
136136
private var z: Int // error
137137
)

0 commit comments

Comments
 (0)