From c005ba9d8ec8f50b8639a9b2c5057416d6253717 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Fri, 28 Nov 2025 01:11:12 +0800 Subject: [PATCH] . --- compiler/src/dotty/tools/dotc/transform/CheckUnused.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala index 745c94d0e904..ccc7aa322c14 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala @@ -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 => @@ -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