Skip to content

Commit

Permalink
Fix WUnused for accessible symbols that are renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-rd committed Mar 29, 2023
1 parent d640193 commit 2071642
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ object CheckUnused:
val qualHasSymbol = qual.tpe.member(sym.name).alternatives.map(_.symbol).contains(sym)
def selector = sels.find(sel => (sel.name.toTermName == sym.name || sel.name.toTypeName == sym.name) && symName.map(n => n.toTermName == sel.rename).getOrElse(true))
def wildcard = sels.find(sel => sel.isWildcard && ((sym.is(Given) == sel.isGiven) || sym.is(Implicit)))
if qualHasSymbol && !isAccessible && sym.exists then
if qualHasSymbol && (!isAccessible || symName.exists(_ != sym.name)) && sym.exists then
selector.orElse(wildcard) // selector with name or wildcard (or given)
else
None
Expand Down
14 changes: 14 additions & 0 deletions tests/neg-custom-args/fatal-warnings/i15503i.scala
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,17 @@ package foo.test.i16679b:
import Foo.x
case class CoolClass(i: Int)
println(summon[myPackage.CaseClassName[CoolClass]])

package foo.test.i17117:
package example {
object test1 {
val test = "test"
}

object test2 {

import example.test1 as t1

val test = t1.test
}
}

0 comments on commit 2071642

Please sign in to comment.