Skip to content

Commit 977232c

Browse files
committed
Rename on import is never wildcard
1 parent b092197 commit 977232c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,11 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
284284
case sel :: sels =>
285285
val matches =
286286
if sel.isWildcard then
287+
// if name is different from sym.name, it must be a rename on import, not a wildcard selector
288+
!name.exists(_.toTermName != sym.name.toTermName)
287289
// the qualifier must have the target symbol as a member
288-
hasAltMember(sym.name) && {
290+
&& hasAltMember(sym.name)
291+
&& {
289292
if sel.isGiven then // Further check that the symbol is a given or implicit and conforms to the bound
290293
sym.isOneOf(GivenOrImplicit)
291294
&& (sel.bound.isEmpty || sym.info.finalResultType <:< sel.boundTpe)

tests/warn/i15503a.scala

+7
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,10 @@ object Suppressed:
321321
object Suppressing:
322322
import Suppressed.* // no warn, see options
323323
def f = 42
324+
325+
package i22692:
326+
import javax.swing.*
327+
import javax.swing.event as swingEvent // no warn, regression test for warning in 3.6
328+
329+
type b = AbstractButton
330+
type t = swingEvent.AncestorListener

0 commit comments

Comments
 (0)