@@ -5,6 +5,7 @@ import dotty.tools.dotc.ast.tpd.*
5
5
import dotty .tools .dotc .ast .untpd , untpd .ImportSelector
6
6
import dotty .tools .dotc .config .ScalaSettings
7
7
import dotty .tools .dotc .core .Contexts .*
8
+ import dotty .tools .dotc .core .Decorators .*
8
9
import dotty .tools .dotc .core .Flags .*
9
10
import dotty .tools .dotc .core .Names .{Name , SimpleName , DerivedName , TermName , termName }
10
11
import dotty .tools .dotc .core .NameOps .{isAnonymousFunctionName , isReplWrapperName , setterName }
@@ -80,7 +81,8 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
80
81
&& tree.qualifier.tpe.match
81
82
case ThisType (_) | SuperType (_, _) => false
82
83
case qualtpe => qualtpe.isStable
83
- if tree.srcPos.isSynthetic && tree.symbol == defn.TypeTest_unapply then
84
+ val sym = tree.symbol.orElse(tree.typeOpt.resultType.typeSymbol)
85
+ if tree.srcPos.isSynthetic && sym == defn.TypeTest_unapply then
84
86
tree.qualifier.tpe.underlying.finalResultType match
85
87
case AppliedType (tycon, args) =>
86
88
val res =
@@ -90,11 +92,11 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
90
92
val target = res.dealias.typeSymbol
91
93
resolveUsage(target, target.name, res.importPrefix.skipPackageObject) // case _: T =>
92
94
case _ =>
93
- else if isImportable || name.exists(_ != tree.symbol .name) then
95
+ else if isImportable || name.exists(_ != sym .name) then
94
96
if ! ignoreTree(tree) then
95
- resolveUsage(tree.symbol , name, tree.qualifier.tpe)
97
+ resolveUsage(sym , name, tree.qualifier.tpe)
96
98
else if ! ignoreTree(tree) then
97
- refUsage(tree.symbol )
99
+ refUsage(sym )
98
100
refInfos.isAssignment = false
99
101
tree
100
102
0 commit comments