Skip to content

Commit 785c8d4

Browse files
committed
Rename {FunctionOf,ContextFunctionOf}.unapply to NonDependent*
1 parent c732a22 commit 785c8d4

File tree

9 files changed

+24
-22
lines changed

9 files changed

+24
-22
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
11491149

11501150
def etaExpandCFT(using Context): Tree =
11511151
def expand(target: Tree, tp: Type)(using Context): Tree = tp match
1152-
case defn.ContextFunctionOf(argTypes, resType) =>
1152+
case defn.NonDependentContextFunctionOf(argTypes, resType) =>
11531153
val anonFun = newAnonFun(
11541154
ctx.owner,
11551155
MethodType.companion(isContextual = true)(argTypes, resType),

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ class CheckCaptures extends Recheck, SymTransformer:
409409
mapArgUsing(_.forceBoxStatus(false))
410410
else if meth == defn.Caps_unsafeBoxFunArg then
411411
mapArgUsing:
412-
case defn.FunctionOf(paramtpe :: Nil, restpe, isContextual) =>
412+
case defn.NonDependentFunctionOf(paramtpe :: Nil, restpe, isContextual) =>
413413
defn.FunctionNOf(paramtpe.forceBoxStatus(true) :: Nil, restpe, isContextual)
414414

415415
else
@@ -531,7 +531,7 @@ class CheckCaptures extends Recheck, SymTransformer:
531531
recheckDef(mdef, meth)
532532
meth.updateInfoBetween(preRecheckPhase, thisPhase, completer)
533533
pt.dealias match
534-
case defn.FunctionOf(ptformals, _, _) => recheckFunction(ptformals)
534+
case defn.NonDependentFunctionOf(ptformals, _, _) => recheckFunction(ptformals)
535535
case defn.DependentFunctionRefinementOf(_, mt) => recheckFunction(mt.paramInfos)
536536
case _ =>
537537
mdef.rhs match
@@ -709,7 +709,7 @@ class CheckCaptures extends Recheck, SymTransformer:
709709
val eparent1 = recur(eparent)
710710
if eparent1 eq eparent then expected
711711
else CapturingType(eparent1, refs, boxed = expected0.isBoxed)
712-
case defn.FunctionOf(args, resultType, isContextual) =>
712+
case defn.NonDependentFunctionOf(args, resultType, isContextual) =>
713713
actual match
714714
case defn.DependentFunctionRefinementOf(_, _) =>
715715
toDepFun(args, resultType, isContextual)
@@ -785,7 +785,7 @@ class CheckCaptures extends Recheck, SymTransformer:
785785

786786
try
787787
val (eargs, eres) = expected.dealias.stripCapturing match
788-
case defn.FunctionOf(eargs, eres, _) => (eargs, eres)
788+
case defn.NonDependentFunctionOf(eargs, eres, _) => (eargs, eres)
789789
case expected: MethodType => (expected.paramInfos, expected.resType)
790790
case expected @ RefinedType(_, _, rinfo: MethodType) if defn.isFunctionNType(expected) => (rinfo.paramInfos, rinfo.resType)
791791
case _ => (aargs.map(_ => WildcardType), WildcardType)

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,9 @@ class Definitions {
11171117
val ft = mt.toFunctionType(isJava = false)
11181118
assert(ft.exists, s"not a valid function type: $mt")
11191119
ft
1120+
}
11201121

1122+
object NonDependentFunctionOf {
11211123
/** Matches a (possibly aliased) `FunctionN[...]`, `ContextFunctionN[...]` or refined `PolyFunction`.
11221124
* Extracts the list of function argument types, the result type and whether function is contextual.
11231125
* It only matches a `PolyFunction` if the function type is not result dependent.
@@ -1156,10 +1158,10 @@ class Definitions {
11561158
* dependent refinements. Optionally returns a triple consisting of the argument
11571159
* types `As`, the result type `B` and a whether the type is an erased context function.
11581160
*/
1159-
object ContextFunctionOf:
1161+
object NonDependentContextFunctionOf:
11601162
def unapply(tp: Type)(using Context): Option[(List[Type], Type)] =
11611163
tp match
1162-
case FunctionOf(argTypes, resultType, true) => Some((argTypes, resultType))
1164+
case NonDependentFunctionOf(argTypes, resultType, true) => Some((argTypes, resultType))
11631165
case _ => None
11641166

11651167
object PolyFunctionOf {
@@ -1173,8 +1175,8 @@ class Definitions {
11731175
*
11741176
* Pattern: `PolyFunction { def apply: $mt }`
11751177
*/
1176-
def unapply(ft: Type)(using Context): Option[MethodicType] = ft.dealias match
1177-
case RefinedType(parent, nme.apply, mt: MethodicType)
1178+
def unapply(ft: Type)(using Context): Option[MethodOrPoly] = ft.dealias match
1179+
case RefinedType(parent, nme.apply, mt: MethodOrPoly)
11781180
if parent.derivesFrom(defn.PolyFunctionClass) =>
11791181
Some(mt)
11801182
case _ => None

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Bridges(root: ClassSymbol, thisPhase: DenotTransformer)(using Context) {
131131
else
132132
val (argTypes, resType, erasedParams) = atPhase(erasurePhase) {
133133
tp match
134-
case defn.ContextFunctionOf(argTypes, resType) =>
134+
case defn.NonDependentContextFunctionOf(argTypes, resType) =>
135135
(argTypes, resType, defn.erasedFunctionParams(tp))
136136
}
137137
val anonFun = newAnonFun(ctx.owner,

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object ContextFunctionResults:
2424
rhs match
2525
case closureDef(meth) => 1 + contextResultCount(meth.rhs, mt.resType)
2626
case _ => 0
27-
case defn.ContextFunctionOf(_, resTpe) =>
27+
case defn.NonDependentContextFunctionOf(_, resTpe) =>
2828
rhs match
2929
case closureDef(meth) => 1 + contextResultCount(meth.rhs, resTpe)
3030
case _ => 0
@@ -64,7 +64,7 @@ object ContextFunctionResults:
6464
def allErased(tp: Type): Boolean = tp.dealias match
6565
case ft @ defn.DependentFunctionRefinementOf(_, mt) if mt.isContextualMethod =>
6666
!defn.erasedFunctionParams(ft).contains(false) && allErased(mt.resType)
67-
case ft @ defn.ContextFunctionOf(_, resTpe) =>
67+
case ft @ defn.NonDependentContextFunctionOf(_, resTpe) =>
6868
!defn.erasedFunctionParams(ft).contains(false) && allErased(resTpe)
6969
case _ => true
7070
contextResultCount(sym) > 0 && allErased(sym.info.finalResultType)
@@ -81,7 +81,7 @@ object ContextFunctionResults:
8181
tp.derivedLambdaType(resType = integrateContextResults(tp.resType, crCount))
8282
case defn.DependentFunctionRefinementOf(base, mt) if mt.isContextualMethod =>
8383
integrateContextResults(base, crCount)
84-
case defn.ContextFunctionOf(argTypes, resType) =>
84+
case defn.NonDependentContextFunctionOf(argTypes, resType) =>
8585
MethodType(argTypes, integrateContextResults(resType, crCount - 1))
8686

8787
/** The total number of parameters of method `sym`, not counting
@@ -92,7 +92,7 @@ object ContextFunctionResults:
9292
def contextParamCount(tp: Type, crCount: Int): Int =
9393
if crCount == 0 then 0
9494
else
95-
val defn.ContextFunctionOf(params, resTpe) = tp: @unchecked
95+
val defn.NonDependentContextFunctionOf(params, resTpe) = tp: @unchecked
9696
val erasedParams = defn.erasedFunctionParams(tp)
9797
val rest = contextParamCount(resTpe, crCount - 1)
9898
if erasedParams.contains(true) then erasedParams.count(_ == false) + rest else params.length + rest
@@ -113,7 +113,7 @@ object ContextFunctionResults:
113113
def recur(tp: Type, n: Int): Type =
114114
if n == 0 then tp
115115
else tp match
116-
case defn.ContextFunctionOf(_, resTpe) => recur(resTpe, n - 1)
116+
case defn.NonDependentContextFunctionOf(_, resTpe) => recur(resTpe, n - 1)
117117
recur(meth.info.finalResultType, depth)
118118

119119
/** Should selection `tree` be eliminated since it refers to an `apply`
@@ -130,7 +130,7 @@ object ContextFunctionResults:
130130
qual.tpe match
131131
case defn.DependentFunctionRefinementOf(_, mt) if mt.isContextualMethod =>
132132
integrateSelect(qual, n + 1)
133-
case defn.ContextFunctionOf(_, _) =>
133+
case defn.NonDependentContextFunctionOf(_, _) =>
134134
integrateSelect(qual, n + 1)
135135
case _ if defn.isContextFunctionClass(tree.symbol.maybeOwner) => // for TermRefs
136136
integrateSelect(qual, n + 1)

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,7 @@ trait Applications extends Compatibility {
19751975
val formals = ref.widen.firstParamTypes
19761976
if formals.length > idx then
19771977
formals(idx) match
1978-
case defn.FunctionOf(args, _, _) => args.length
1978+
case defn.NonDependentFunctionOf(args, _, _) => args.length
19791979
case _ => -1
19801980
else -1
19811981

@@ -2061,7 +2061,7 @@ trait Applications extends Compatibility {
20612061

20622062
case pt =>
20632063
val compat0 = pt match
2064-
case defn.FunctionOf(args, resType, _) =>
2064+
case defn.NonDependentFunctionOf(args, resType, _) =>
20652065
narrowByTypes(alts, args, resType)
20662066
case _ =>
20672067
Nil
@@ -2226,7 +2226,7 @@ trait Applications extends Compatibility {
22262226
val formalsForArg: List[Type] = altFormals.map(_.head)
22272227
def argTypesOfFormal(formal: Type): List[Type] =
22282228
formal.dealias match {
2229-
case defn.FunctionOf(args, result, isImplicit) => args
2229+
case defn.NonDependentFunctionOf(args, result, isImplicit) => args
22302230
case defn.PartialFunctionOf(arg, result) => arg :: Nil
22312231
case _ => Nil
22322232
}

compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ object ErrorReporting {
167167
val normPt = normalize(pt, pt)
168168

169169
def contextFunctionCount(tp: Type): Int = tp.stripped match
170-
case defn.ContextFunctionOf(_, restp) => 1 + contextFunctionCount(restp)
170+
case defn.NonDependentContextFunctionOf(_, restp) => 1 + contextFunctionCount(restp)
171171
case _ => 0
172172
def strippedTpCount = contextFunctionCount(tree.tpe) - contextFunctionCount(normTp)
173173
def strippedPtCount = contextFunctionCount(pt) - contextFunctionCount(normPt)

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ class Namer { typer: Typer =>
18961896
case defn.DependentFunctionRefinementOf(_, mt) if mt.isContextualMethod =>
18971897
// in this case `resType` is lying, gives us only the non-dependent upper bound
18981898
originalTp
1899-
case atp @ defn.ContextFunctionOf(_, resType)
1899+
case atp @ defn.NonDependentContextFunctionOf(_, resType)
19001900
if resType.existsPart(_.isInstanceOf[WildcardType], StopAt.Static, forceLazy = false) =>
19011901
originalTp
19021902
case _ =>

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3193,7 +3193,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
31933193
tree
31943194

31953195
protected def makeContextualFunction(tree: untpd.Tree, pt: Type)(using Context): Tree = {
3196-
val defn.FunctionOf(formals, _, true) = pt.dropDependentRefinement: @unchecked
3196+
val defn.NonDependentContextFunctionOf(formals, _) = pt.dropDependentRefinement: @unchecked
31973197

31983198
// The getter of default parameters may reach here.
31993199
// Given the code below

0 commit comments

Comments
 (0)