Skip to content

Commit

Permalink
Backport "Fix false positive in WUnused for renamed path-dependent im…
Browse files Browse the repository at this point in the history
…ports (2)" to LTS (#20637)

Backports #18617 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 20, 2024
2 parents b015099 + db45a20 commit 827a675
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ object CheckUnused:
* - usage
*/
private class UnusedData:
import collection.mutable.{Set => MutSet, Map => MutMap, Stack => MutStack}
import collection.mutable.{Set => MutSet, Map => MutMap, Stack => MutStack, ListBuffer => MutList}
import UnusedData.*

/** The current scope during the tree traversal */
Expand All @@ -346,7 +346,7 @@ object CheckUnused:
var unusedAggregate: Option[UnusedResult] = None

/* IMPORTS */
private val impInScope = MutStack(MutSet[tpd.Import]())
private val impInScope = MutStack(MutList[tpd.Import]())
/**
* We store the symbol along with their accessibility without import.
* Accessibility to their definition in outer context/scope
Expand Down Expand Up @@ -449,7 +449,7 @@ object CheckUnused:
def pushScope(newScopeType: ScopeType): Unit =
// unused imports :
currScopeType.push(newScopeType)
impInScope.push(MutSet())
impInScope.push(MutList())
usedInScope.push(MutSet())

def registerSetVar(sym: Symbol): Unit =
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/i18366.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//> using options -Xfatal-warnings -Wunused:all

trait Builder {
def foo(): Unit
}

def repro =
val builder: Builder = ???
import builder.{foo => bar}
bar()

0 comments on commit 827a675

Please sign in to comment.