Skip to content

Commit c005ba9

Browse files
committed
.
1 parent 0470ec1 commit c005ba9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
351351
|| nm.isTypeName && alt.symbol.isAliasType && alt.info.dealias.typeSymbol == sym
352352
sameSym && alt.symbol.isAccessibleFrom(qtpe)
353353
def hasAltMemberNamed(nm: Name) = qtpe.member(nm).hasAltWith(_.symbol.isAccessibleFrom(qtpe))
354+
def hasTypeAlias(nm: Name) = nm.isTypeName && qtpe.member(nm).hasAltWith: alt =>
355+
alt.symbol.isAliasType && alt.info.dealias.typeSymbol == sym && alt.symbol.isAccessibleFrom(qtpe)
354356

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

0 commit comments

Comments
 (0)