Skip to content
Open
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
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
|| nm.isTypeName && alt.symbol.isAliasType && alt.info.dealias.typeSymbol == sym
sameSym && alt.symbol.isAccessibleFrom(qtpe)
def hasAltMemberNamed(nm: Name) = qtpe.member(nm).hasAltWith(_.symbol.isAccessibleFrom(qtpe))
def hasTypeAlias(nm: Name) = nm.isTypeName && qtpe.member(nm).hasAltWith: alt =>
alt.symbol.isAliasType && alt.info.dealias.typeSymbol == sym && alt.symbol.isAccessibleFrom(qtpe)

def loop(sels: List[ImportSelector]): ImportSelector | Null = sels match
case sel :: sels =>
Expand Down Expand Up @@ -379,7 +381,7 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
false
else
!name.exists(_.toTermName != sel.rename) // if there is an explicit name, it must match
&& (prefix.eq(NoPrefix) || qtpe =:= prefix)
&& (prefix.eq(NoPrefix) || qtpe =:= prefix || hasTypeAlias(sel.name.toTypeName))
&& (hasAltMember(sel.name) || hasAltMember(sel.name.toTypeName))
if matches then sel else loop(sels)
case nil => null
Expand Down
Loading