Skip to content

Commit 1b48670

Browse files
som-snytttgodzik
authored andcommitted
Collectivize contextual param in extensions
1 parent 8736ff8 commit 1b48670

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -883,20 +883,20 @@ object CheckUnused:
883883
inline def exists(p: Name => Boolean): Boolean = nm.ne(nme.NO_NAME) && p(nm)
884884
inline def isWildcard: Boolean = nm == nme.WILDCARD || nm.is(WildcardParamName)
885885

886-
extension (tp: Type)
887-
def importPrefix(using Context): Type = tp match
886+
extension (tp: Type)(using Context)
887+
def importPrefix: Type = tp match
888888
case tp: NamedType => tp.prefix
889889
case tp: ClassInfo => tp.prefix
890890
case tp: TypeProxy => tp.superType.normalizedPrefix
891891
case _ => NoType
892-
def underlyingPrefix(using Context): Type = tp match
892+
def underlyingPrefix: Type = tp match
893893
case tp: NamedType => tp.prefix
894894
case tp: ClassInfo => tp.prefix
895895
case tp: TypeProxy => tp.underlying.underlyingPrefix
896896
case _ => NoType
897-
def skipPackageObject(using Context): Type =
897+
def skipPackageObject: Type =
898898
if tp.typeSymbol.isPackageObject then tp.underlyingPrefix else tp
899-
def underlying(using Context): Type = tp match
899+
def underlying: Type = tp match
900900
case tp: TypeProxy => tp.underlying
901901
case _ => tp
902902

@@ -913,6 +913,9 @@ object CheckUnused:
913913
sym.isClass && sym.info.allMembers.forall: d =>
914914
val m = d.symbol
915915
!m.isTerm || m.isSelfSym || m.is(Method) && (m.owner == defn.AnyClass || m.owner == defn.ObjectClass)
916+
def isEffectivelyPrivate: Boolean =
917+
sym.is(Private, butNot = ParamAccessor)
918+
|| sym.owner.isAnonymousClass && !sym.isEffectivelyOverride
916919
def isEffectivelyOverride: Boolean =
917920
sym.is(Override)
918921
||
@@ -921,11 +924,6 @@ object CheckUnused:
921924
val base = if owner.classInfo.selfInfo != NoType then owner.thisType else owner.info
922925
base.baseClasses.drop(1).iterator.exists(sym.overriddenSymbol(_).exists)
923926
}
924-
def isEffectivelyPrivate: Boolean =
925-
sym.is(Private, butNot = ParamAccessor)
926-
|| sym.owner.isAnonymousClass && !sym.isEffectivelyOverride
927-
def isEffectivelyOverride(using Context): Boolean =
928-
sym.is(Override) || sym.nextOverriddenSymbol.exists
929927
// pick the symbol the user wrote for purposes of tracking
930928
inline def userSymbol: Symbol=
931929
if sym.denot.is(ModuleClass) then sym.denot.companionModule else sym
@@ -941,21 +939,21 @@ object CheckUnused:
941939
case untpd.Ident(nme.WILDCARD) => true
942940
case _ => false
943941

944-
extension (imp: Import)
942+
extension (imp: Import)(using Context)
945943
/** Is it the first import clause in a statement? `a.x` in `import a.x, b.{y, z}` */
946-
def isPrimaryClause(using Context): Boolean =
944+
def isPrimaryClause: Boolean =
947945
imp.srcPos.span.pointDelta > 0 // primary clause starts at `import` keyword with point at clause proper
948946

949947
/** Generated import of cases from enum companion. */
950-
def isGeneratedByEnum(using Context): Boolean =
948+
def isGeneratedByEnum: Boolean =
951949
imp.symbol.exists && imp.symbol.owner.is(Enum, butNot = Case)
952950

953951
/** Under -Wunused:strict-no-implicit-warn, avoid false positives
954952
* if this selector is a wildcard that might import implicits or
955953
* specifically does import an implicit.
956954
* Similarly, import of CanEqual must not warn, as it is always witness.
957955
*/
958-
def isLoose(sel: ImportSelector)(using Context): Boolean =
956+
def isLoose(sel: ImportSelector): Boolean =
959957
if ctx.settings.WunusedHas.strictNoImplicitWarn then
960958
if sel.isWildcard
961959
|| imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit))

0 commit comments

Comments
 (0)