Skip to content

Commit 819586f

Browse files
committed
Collectivize contextual param in extensions
1 parent 1da6599 commit 819586f

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -892,43 +892,43 @@ object CheckUnused:
892892
inline def exists(p: Name => Boolean): Boolean = nm.ne(nme.NO_NAME) && p(nm)
893893
inline def isWildcard: Boolean = nm == nme.WILDCARD || nm.is(WildcardParamName)
894894

895-
extension (tp: Type)
896-
def importPrefix(using Context): Type = tp match
895+
extension (tp: Type)(using Context)
896+
def importPrefix: Type = tp match
897897
case tp: NamedType => tp.prefix
898898
case tp: ClassInfo => tp.prefix
899899
case tp: TypeProxy => tp.superType.normalizedPrefix
900900
case _ => NoType
901-
def underlyingPrefix(using Context): Type = tp match
901+
def underlyingPrefix: Type = tp match
902902
case tp: NamedType => tp.prefix
903903
case tp: ClassInfo => tp.prefix
904904
case tp: TypeProxy => tp.underlying.underlyingPrefix
905905
case _ => NoType
906-
def skipPackageObject(using Context): Type =
906+
def skipPackageObject: Type =
907907
if tp.typeSymbol.isPackageObject then tp.underlyingPrefix else tp
908-
def underlying(using Context): Type = tp match
908+
def underlying: Type = tp match
909909
case tp: TypeProxy => tp.underlying
910910
case _ => tp
911911

912912
private val serializationNames: Set[TermName] =
913913
Set("readResolve", "readObject", "readObjectNoData", "writeObject", "writeReplace").map(termName(_))
914914

915-
extension (sym: Symbol)
916-
def isSerializationSupport(using Context): Boolean =
915+
extension (sym: Symbol)(using Context)
916+
def isSerializationSupport: Boolean =
917917
sym.is(Method) && serializationNames(sym.name.toTermName) && sym.owner.isClass
918918
&& sym.owner.derivesFrom(defn.JavaSerializableClass)
919-
def isCanEqual(using Context): Boolean =
919+
def isCanEqual: Boolean =
920920
sym.isOneOf(GivenOrImplicit) && sym.info.finalResultType.baseClasses.exists(_.derivesFrom(defn.CanEqualClass))
921-
def isMarkerTrait(using Context): Boolean =
921+
def isMarkerTrait: Boolean =
922922
sym.isClass && sym.info.allMembers.forall: d =>
923923
val m = d.symbol
924924
!m.isTerm || m.isSelfSym || m.is(Method) && (m.owner == defn.AnyClass || m.owner == defn.ObjectClass)
925-
def isEffectivelyPrivate(using Context): Boolean =
925+
def isEffectivelyPrivate: Boolean =
926926
sym.is(Private, butNot = ParamAccessor)
927927
|| sym.owner.isAnonymousClass && !sym.isEffectivelyOverride
928-
def isEffectivelyOverride(using Context): Boolean =
928+
def isEffectivelyOverride: Boolean =
929929
sym.is(Override) || sym.nextOverriddenSymbol.exists
930930
// pick the symbol the user wrote for purposes of tracking
931-
inline def userSymbol(using Context): Symbol=
931+
inline def userSymbol: Symbol=
932932
if sym.denot.is(ModuleClass) then sym.denot.companionModule else sym
933933

934934
extension (sel: ImportSelector)
@@ -942,21 +942,21 @@ object CheckUnused:
942942
case untpd.Ident(nme.WILDCARD) => true
943943
case _ => false
944944

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

950950
/** Generated import of cases from enum companion. */
951-
def isGeneratedByEnum(using Context): Boolean =
951+
def isGeneratedByEnum: Boolean =
952952
imp.symbol.exists && imp.symbol.owner.is(Enum, butNot = Case)
953953

954954
/** Under -Wunused:strict-no-implicit-warn, avoid false positives
955955
* if this selector is a wildcard that might import implicits or
956956
* specifically does import an implicit.
957957
* Similarly, import of CanEqual must not warn, as it is always witness.
958958
*/
959-
def isLoose(sel: ImportSelector)(using Context): Boolean =
959+
def isLoose(sel: ImportSelector): Boolean =
960960
if ctx.settings.WunusedHas.strictNoImplicitWarn then
961961
if sel.isWildcard
962962
|| imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit))

0 commit comments

Comments
 (0)