@@ -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 , NameFilter , NamedType , 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
@@ -82,6 +77,12 @@ class CheckUnused extends MiniPhase:
82
77
83
78
override def prepareForIdent (tree : tpd.Ident )(using Context ): Context =
84
79
if tree.symbol.exists then
80
+ val prefixes = LazyList .iterate(tree.typeOpt.normalizedPrefix)(_.normalizedPrefix).takeWhile(_ != NoType )
81
+ for {
82
+ prefix <- prefixes
83
+ } {
84
+ unusedDataApply(_.registerUsed(prefix.classSymbol, None ))
85
+ }
85
86
unusedDataApply(_.registerUsed(tree.symbol, Some (tree.name)))
86
87
else if tree.hasType then
87
88
unusedDataApply(_.registerUsed(tree.tpe.classSymbol, Some (tree.name)))
@@ -409,7 +410,6 @@ object CheckUnused:
409
410
val kept = used.filterNot { t =>
410
411
val (sym, isAccessible, optName) = t
411
412
// keep the symbol for outer scope, if it matches **no** import
412
-
413
413
// This is the first matching wildcard selector
414
414
var selWildCard : Option [ImportSelector ] = None
415
415
0 commit comments