@@ -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 }
@@ -360,7 +360,7 @@ object CheckUnused:
360
360
361
361
/** Register an import */
362
362
def registerImport (imp : tpd.Import )(using Context ): Unit =
363
- if ! tpd.languageImport(imp.expr).nonEmpty && ! imp.isGeneratedByEnum then
363
+ if ! tpd.languageImport(imp.expr).nonEmpty && ! imp.isGeneratedByEnum && ! isTransparentAndInline(imp) then
364
364
impInScope.top += imp
365
365
unusedImport ++= imp.selectors.filter { s =>
366
366
! shouldSelectorBeReported(imp, s) && ! isImportExclusion(s)
@@ -426,19 +426,6 @@ object CheckUnused:
426
426
exists
427
427
}
428
428
429
- // not report unused transparent inline imports
430
- for {
431
- imp <- imports
432
- sel <- imp.selectors
433
- } {
434
- if unusedImport.contains(sel) then
435
- val tpd .Import (qual, _) = imp
436
- val importedMembers = qual.tpe.member(sel.name).alternatives.map(_.symbol)
437
- val isTransparentAndInline = importedMembers.exists(s => s.is(Transparent ) && s.is(Inline ))
438
- if isTransparentAndInline then
439
- unusedImport -= sel
440
- }
441
-
442
429
// if there's an outer scope
443
430
if usedInScope.nonEmpty then
444
431
// we keep the symbols not referencing an import in this scope
@@ -513,6 +500,18 @@ object CheckUnused:
513
500
end getUnused
514
501
// ============================ HELPERS ====================================
515
502
503
+
504
+ /**
505
+ * Checks if import selects a def that is transparent and inline
506
+ */
507
+ private def isTransparentAndInline (imp : tpd.Import )(using Context ): Boolean =
508
+ (for {
509
+ sel <- imp.selectors
510
+ } yield {
511
+ val qual = imp.expr
512
+ val importedMembers = qual.tpe.member(sel.name).alternatives.map(_.symbol)
513
+ importedMembers.exists(s => s.is(Transparent ) && s.is(Inline ))
514
+ }).exists(identity)
516
515
/**
517
516
* Heuristic to detect synthetic suffixes in names of symbols
518
517
*/
0 commit comments