@@ -10,7 +10,7 @@ import dotty.tools.dotc.core.Decorators.{em, i}
10
10
import dotty .tools .dotc .core .Flags .*
11
11
import dotty .tools .dotc .core .Phases .Phase
12
12
import dotty .tools .dotc .core .StdNames
13
- import dotty .tools .dotc .{ ast , report }
13
+ import dotty .tools .dotc .report
14
14
import dotty .tools .dotc .reporting .Message
15
15
import dotty .tools .dotc .typer .ImportInfo
16
16
import dotty .tools .dotc .util .{Property , SrcPos }
@@ -365,7 +365,7 @@ object CheckUnused:
365
365
366
366
/** Register an import */
367
367
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
369
369
impInScope.top += imp
370
370
unusedImport ++= imp.selectors.filter { s =>
371
371
! shouldSelectorBeReported(imp, s) && ! isImportExclusion(s)
@@ -431,19 +431,6 @@ object CheckUnused:
431
431
exists
432
432
}
433
433
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
-
447
434
// if there's an outer scope
448
435
if usedInScope.nonEmpty then
449
436
// we keep the symbols not referencing an import in this scope
@@ -518,6 +505,18 @@ object CheckUnused:
518
505
end getUnused
519
506
// ============================ HELPERS ====================================
520
507
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)
521
520
/**
522
521
* Heuristic to detect synthetic suffixes in names of symbols
523
522
*/
0 commit comments