@@ -5,6 +5,7 @@ import dotty.tools.dotc.ast.tpd.*
55import dotty .tools .dotc .ast .untpd , untpd .ImportSelector
66import dotty .tools .dotc .config .ScalaSettings
77import dotty .tools .dotc .core .Contexts .*
8+ import dotty .tools .dotc .core .Decorators .*
89import dotty .tools .dotc .core .Flags .*
910import dotty .tools .dotc .core .Names .{Name , SimpleName , DerivedName , TermName , termName }
1011import dotty .tools .dotc .core .NameOps .{isAnonymousFunctionName , isReplWrapperName , setterName }
@@ -80,7 +81,8 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
8081 && tree.qualifier.tpe.match
8182 case ThisType (_) | SuperType (_, _) => false
8283 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
8486 tree.qualifier.tpe.underlying.finalResultType match
8587 case AppliedType (tycon, args) =>
8688 val res =
@@ -90,11 +92,11 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
9092 val target = res.dealias.typeSymbol
9193 resolveUsage(target, target.name, res.importPrefix.skipPackageObject) // case _: T =>
9294 case _ =>
93- else if isImportable || name.exists(_ != tree.symbol .name) then
95+ else if isImportable || name.exists(_ != sym .name) then
9496 if ! ignoreTree(tree) then
95- resolveUsage(tree.symbol , name, tree.qualifier.tpe)
97+ resolveUsage(sym , name, tree.qualifier.tpe)
9698 else if ! ignoreTree(tree) then
97- refUsage(tree.symbol )
99+ refUsage(sym )
98100 refInfos.isAssignment = false
99101 tree
100102
0 commit comments