@@ -10,7 +10,7 @@ import dotty.tools.dotc.core.Decorators.{em, i}
1010import dotty .tools .dotc .core .Flags .*
1111import dotty .tools .dotc .core .Phases .Phase
1212import dotty .tools .dotc .core .StdNames
13- import dotty .tools .dotc .{ ast , report }
13+ import dotty .tools .dotc .report
1414import dotty .tools .dotc .reporting .Message
1515import dotty .tools .dotc .typer .ImportInfo
1616import dotty .tools .dotc .util .{Property , SrcPos }
@@ -365,7 +365,7 @@ object CheckUnused:
365365
366366 /** Register an import */
367367 def registerImport (imp : tpd.Import )(using Context ): Unit =
368- if ! tpd.languageImport(imp.expr).nonEmpty && ! imp.isGeneratedByEnum then
368+ if ! tpd.languageImport(imp.expr).nonEmpty && ! imp.isGeneratedByEnum && ! isTransparentAndInline(imp) then
369369 impInScope.top += imp
370370 unusedImport ++= imp.selectors.filter { s =>
371371 ! shouldSelectorBeReported(imp, s) && ! isImportExclusion(s)
@@ -431,19 +431,6 @@ object CheckUnused:
431431 exists
432432 }
433433
434- // not report unused transparent inline imports
435- for {
436- imp <- imports
437- sel <- imp.selectors
438- } {
439- if unusedImport.contains(sel) then
440- val tpd .Import (qual, _) = imp
441- val importedMembers = qual.tpe.member(sel.name).alternatives.map(_.symbol)
442- val isTransparentAndInline = importedMembers.exists(s => s.is(Transparent ) && s.is(Inline ))
443- if isTransparentAndInline then
444- unusedImport -= sel
445- }
446-
447434 // if there's an outer scope
448435 if usedInScope.nonEmpty then
449436 // we keep the symbols not referencing an import in this scope
@@ -518,6 +505,18 @@ object CheckUnused:
518505 end getUnused
519506 // ============================ HELPERS ====================================
520507
508+
509+ /**
510+ * Checks if import selects a def that is transparent and inline
511+ */
512+ private def isTransparentAndInline (imp : tpd.Import )(using Context ): Boolean =
513+ (for {
514+ sel <- imp.selectors
515+ } yield {
516+ val qual = imp.expr
517+ val importedMembers = qual.tpe.member(sel.name).alternatives.map(_.symbol)
518+ importedMembers.exists(s => s.is(Transparent ) && s.is(Inline ))
519+ }).exists(identity)
521520 /**
522521 * Heuristic to detect synthetic suffixes in names of symbols
523522 */
0 commit comments