@@ -25,6 +25,7 @@ import dotty.tools.dotc.util.chaining.*
25
25
26
26
import java .util .IdentityHashMap
27
27
28
+ import scala .collection .immutable .LazyList
28
29
import scala .collection .mutable , mutable .{ArrayBuilder , ListBuffer , Stack }
29
30
30
31
import CheckUnused .*
@@ -63,8 +64,22 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
63
64
if depth < 10 && prefix.exists && ! prefix.classSymbol.isEffectiveRoot then
64
65
resolveUsage(prefix.classSymbol, nme.NO_NAME , NoPrefix )
65
66
loopOverPrefixes(prefix.normalizedPrefix, depth + 1 )
67
+ /*
66
68
if tree.srcPos.isZeroExtentSynthetic then
67
- loopOverPrefixes(tree.typeOpt.normalizedPrefix, depth = 0 )
69
+ println(s"ZES ${tree.show}")
70
+ def prefixed(t: Type) =
71
+ if t.exists && !t.classSymbol.isEffectiveRoot then
72
+ println(s"CS ${t.classSymbol}")
73
+ Some(t, t.normalizedPrefix)
74
+ else
75
+ None
76
+ val prefixes = LazyList.unfold(tree.typeOpt)(prefixed).take(10).force
77
+ println(s"PREFIXES ${prefixes}")
78
+ for (prefix <- prefixes.drop(1))
79
+ ()
80
+ */
81
+ // if tree.srcPos.isZeroExtentSynthetic then
82
+ // loopOverPrefixes(tree.typeOpt.normalizedPrefix, depth = 0)
68
83
resolveUsage(tree.symbol, tree.name, tree.typeOpt.importPrefix.skipPackageObject)
69
84
else if tree.hasType then
70
85
resolveUsage(tree.tpe.classSymbol, tree.name, tree.tpe.importPrefix.skipPackageObject)
@@ -330,7 +345,7 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
330
345
def addCached (where : Context , result : Precedence ): Unit =
331
346
if where.moreProperties ne null then
332
347
where.property(resolvedKey) match
333
- case Some (resolved) =>
348
+ case Some (resolved) if where.owner.isLocalToBlock || where.owner.info =:= prefix =>
334
349
resolved.record(sym, name, prefix, result)
335
350
case none =>
336
351
@@ -361,7 +376,7 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
361
376
cur.property(resolvedKey) match
362
377
case Some (resolved) =>
363
378
// conservative, cache must be nested below the result context
364
- if precedence.isNone then
379
+ if precedence.isNone && (cur.owner.isLocalToBlock || cur.owner.info =:= prefix) then
365
380
cachePoint = cur // no result yet, and future result could be cached here
366
381
resolved.hasRecord(sym, name, prefix)
367
382
case none => NoPrecedence
0 commit comments