@@ -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 }
@@ -368,7 +368,7 @@ object CheckUnused:
368
368
369
369
/** Register an import */
370
370
def registerImport (imp : tpd.Import )(using Context ): Unit =
371
- if ! tpd.languageImport(imp.expr).nonEmpty && ! imp.isGeneratedByEnum then
371
+ if ! tpd.languageImport(imp.expr).nonEmpty && ! imp.isGeneratedByEnum && ! isTransparentAndInline(imp) then
372
372
impInScope.top += imp
373
373
unusedImport ++= imp.selectors.filter { s =>
374
374
! shouldSelectorBeReported(imp, s) && ! isImportExclusion(s)
@@ -433,19 +433,6 @@ object CheckUnused:
433
433
exists
434
434
}
435
435
436
- // not report unused transparent inline imports
437
- for {
438
- imp <- imports
439
- sel <- imp.selectors
440
- } {
441
- if unusedImport.contains(sel) then
442
- val tpd .Import (qual, _) = imp
443
- val importedMembers = qual.tpe.member(sel.name).alternatives.map(_.symbol)
444
- val isTransparentAndInline = importedMembers.exists(s => s.is(Transparent ) && s.is(Inline ))
445
- if isTransparentAndInline then
446
- unusedImport -= sel
447
- }
448
-
449
436
// if there's an outer scope
450
437
if usedInScope.nonEmpty then
451
438
// we keep the symbols not referencing an import in this scope
@@ -520,6 +507,18 @@ object CheckUnused:
520
507
end getUnused
521
508
// ============================ HELPERS ====================================
522
509
510
+
511
+ /**
512
+ * Checks if import selects a def that is transparent and inline
513
+ */
514
+ private def isTransparentAndInline (imp : tpd.Import )(using Context ): Boolean =
515
+ (for {
516
+ sel <- imp.selectors
517
+ } yield {
518
+ val qual = imp.expr
519
+ val importedMembers = qual.tpe.member(sel.name).alternatives.map(_.symbol)
520
+ importedMembers.exists(s => s.is(Transparent ) && s.is(Inline ))
521
+ }).exists(identity)
523
522
/**
524
523
* Heuristic to detect synthetic suffixes in names of symbols
525
524
*/
0 commit comments