@@ -639,7 +639,6 @@ object CheckUnused:
639
639
|| m.is(Synthetic )
640
640
|| m.hasAnnotation(dd.UnusedAnnot ) // param of unused method
641
641
|| sym.owner.name.isContextFunction // a ubiquitous parameter
642
- || sym.isCanEqual
643
642
|| sym.info.dealias.typeSymbol.match // more ubiquity
644
643
case dd.DummyImplicitClass | dd.SubTypeClass | dd.SameTypeClass => true
645
644
case tps =>
@@ -671,7 +670,6 @@ object CheckUnused:
671
670
def checkLocal (sym : Symbol , pos : SrcPos ) =
672
671
if ctx.settings.WunusedHas .locals
673
672
&& ! sym.is(InlineProxy )
674
- && ! sym.isCanEqual
675
673
then
676
674
if sym.is(Mutable ) && infos.asss(sym) then
677
675
warnAt(pos)(UnusedSymbol .localVars)
@@ -703,7 +701,9 @@ object CheckUnused:
703
701
import scala .jdk .CollectionConverters .given
704
702
import Rewrites .ActionPatch
705
703
type ImpSel = (Import , ImportSelector )
706
- def isUsed (sel : ImportSelector ): Boolean = infos.sels.containsKey(sel)
704
+ // true if used or might be used, to imply don't warn about it
705
+ def isUsable (imp : Import , sel : ImportSelector ): Boolean =
706
+ sel.isImportExclusion || infos.sels.containsKey(sel)
707
707
def warnImport (warnable : ImpSel , actions : List [CodeAction ] = Nil ): Unit =
708
708
val (imp, sel) = warnable
709
709
val msg = UnusedSymbol .imports(actions)
@@ -978,8 +978,6 @@ object CheckUnused:
978
978
def isSerializationSupport : Boolean =
979
979
sym.is(Method ) && serializationNames(sym.name.toTermName) && sym.owner.isClass
980
980
&& sym.owner.derivesFrom(defn.JavaSerializableClass )
981
- def isCanEqual : Boolean =
982
- sym.isOneOf(GivenOrImplicit ) && sym.info.finalResultType.baseClasses.exists(_.derivesFrom(defn.CanEqualClass ))
983
981
def isMarkerTrait : Boolean =
984
982
sym.info.hiBound.resultType.allMembers.forall: d =>
985
983
val m = d.symbol
@@ -1013,21 +1011,6 @@ object CheckUnused:
1013
1011
def isGeneratedByEnum : Boolean =
1014
1012
imp.symbol.exists && imp.symbol.owner.is(Enum , butNot = Case )
1015
1013
1016
- /** Under -Wunused:strict-no-implicit-warn, avoid false positives
1017
- * if this selector is a wildcard that might import implicits or
1018
- * specifically does import an implicit.
1019
- * Similarly, import of CanEqual must not warn, as it is always witness.
1020
- */
1021
- def isLoose (sel : ImportSelector ): Boolean =
1022
- if ctx.settings.WunusedHas .strictNoImplicitWarn then
1023
- if sel.isWildcard
1024
- || imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit ))
1025
- || imp.expr.tpe.member(sel.name.toTypeName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit ))
1026
- then return true
1027
- if sel.isWildcard && sel.isGiven
1028
- then imp.expr.tpe.allMembers.exists(_.symbol.isCanEqual)
1029
- else imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isCanEqual)
1030
-
1031
1014
extension (pos : SrcPos )
1032
1015
def isZeroExtentSynthetic : Boolean = pos.span.isSynthetic && pos.span.isZeroExtent
1033
1016
def isSynthetic : Boolean = pos.span.isSynthetic && pos.span.exists
0 commit comments