Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,10 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
def matchingSelector(info: ImportInfo): ImportSelector | Null =
val qtpe = info.site
def hasAltMember(nm: Name) = qtpe.member(nm).hasAltWith: alt =>
alt.symbol == sym
|| nm.isTypeName && alt.symbol.isAliasType && alt.info.dealias.typeSymbol == sym
val sameSym =
alt.symbol == sym
|| nm.isTypeName && alt.symbol.isAliasType && alt.info.dealias.typeSymbol == sym
sameSym && alt.symbol.isAccessibleFrom(qtpe)
def loop(sels: List[ImportSelector]): ImportSelector | Null = sels match
case sel :: sels =>
val matches =
Expand Down
22 changes: 22 additions & 0 deletions tests/warn/i23347.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//> using options -Wunused:all

object USED {
case class A(value: Int)
}

object UNUSED {
// In reality UNUSED would contain several other necessary members!
private type A = USED.A // warn private
class B
}

object Test {
import USED.*
import UNUSED.*

def foo(a: A): Int = a.value

def g(b: B) = ()

}

Loading