1
1
package dotty .tools .dotc .transform
2
2
3
3
import dotty .tools .dotc .ast .tpd
4
- import dotty .tools .dotc .ast .tpd .TreeTraverser
4
+ import dotty .tools .dotc .ast .tpd .{ Inlined , TreeTraverser }
5
5
import dotty .tools .dotc .ast .untpd
6
6
import dotty .tools .dotc .ast .untpd .ImportSelector
7
7
import dotty .tools .dotc .config .ScalaSettings
@@ -15,19 +15,14 @@ import dotty.tools.dotc.reporting.Message
15
15
import dotty .tools .dotc .typer .ImportInfo
16
16
import dotty .tools .dotc .util .{Property , SrcPos }
17
17
import dotty .tools .dotc .core .Mode
18
- import dotty .tools .dotc .core .Types .TypeTraverser
19
- import dotty .tools .dotc .core .Types .Type
20
- import dotty .tools .dotc .core .Types .AnnotatedType
18
+ import dotty .tools .dotc .core .Types .{AnnotatedType , ConstantType , NoType , TermRef , Type , TypeTraverser }
21
19
import dotty .tools .dotc .core .Flags .flagsString
22
20
import dotty .tools .dotc .core .Flags
23
21
import dotty .tools .dotc .core .Names .Name
24
22
import dotty .tools .dotc .transform .MegaPhase .MiniPhase
25
23
import dotty .tools .dotc .core .Annotations
26
24
import dotty .tools .dotc .core .Definitions
27
- import dotty .tools .dotc .core .Types .ConstantType
28
25
import dotty .tools .dotc .core .NameKinds .WildcardParamName
29
- import dotty .tools .dotc .core .Types .TermRef
30
- import dotty .tools .dotc .core .Types .NameFilter
31
26
import dotty .tools .dotc .core .Symbols .Symbol
32
27
33
28
@@ -80,8 +75,16 @@ class CheckUnused extends MiniPhase:
80
75
traverser.traverse(tree)
81
76
ctx
82
77
78
+ override def prepareForInlined (tree : tpd.Inlined )(using Context ): Context =
79
+ traverser.traverse(tree.call)
80
+ ctx
81
+
83
82
override def prepareForIdent (tree : tpd.Ident )(using Context ): Context =
84
83
if tree.symbol.exists then
84
+ val prefixes = LazyList .iterate(tree.typeOpt.normalizedPrefix)(_.normalizedPrefix).takeWhile(_ != NoType )
85
+ .take(10 ) // Failsafe for the odd case if there was an infinite cycle
86
+ for prefix <- prefixes do
87
+ unusedDataApply(_.registerUsed(prefix.classSymbol, None ))
85
88
unusedDataApply(_.registerUsed(tree.symbol, Some (tree.name)))
86
89
else if tree.hasType then
87
90
unusedDataApply(_.registerUsed(tree.tpe.classSymbol, Some (tree.name)))
@@ -409,7 +412,6 @@ object CheckUnused:
409
412
val kept = used.filterNot { t =>
410
413
val (sym, isAccessible, optName) = t
411
414
// keep the symbol for outer scope, if it matches **no** import
412
-
413
415
// This is the first matching wildcard selector
414
416
var selWildCard : Option [ImportSelector ] = None
415
417
0 commit comments