From 4c0ddac145b2ef1599a4832a5d6f02c7076cef33 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Tue, 4 Mar 2025 15:56:39 -0800 Subject: [PATCH] Rename is never wildcard import --- compiler/src/dotty/tools/dotc/transform/CheckUnused.scala | 4 +++- tests/warn/i22692.scala | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/warn/i22692.scala diff --git a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala index 6e626fc5dd9e..ccbf13567e35 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala @@ -726,8 +726,10 @@ object CheckUnused: else selData.allSymbolsForNamed.contains(sym) else + if altName.exists(alt => alt.toTermName != sym.name.toTermName) then // rename is never a wildcard import + false // Wildcard - if selData.excludedMembers.contains(altName.getOrElse(sym.name).toTermName) then + else if selData.excludedMembers.contains(altName.getOrElse(sym.name).toTermName) then // Wildcard with exclusions that match the symbol false else if !selData.qualTpe.member(sym.name).hasAltWith(_.symbol == sym) then diff --git a/tests/warn/i22692.scala b/tests/warn/i22692.scala new file mode 100644 index 000000000000..276bbd8b7977 --- /dev/null +++ b/tests/warn/i22692.scala @@ -0,0 +1,8 @@ + +//> using options -Wunused:all + +import javax.swing.* +import javax.swing.event as swingEvent + +type b = AbstractButton +type t = swingEvent.AncestorListener