Skip to content

Commit d7167b0

Browse files
committed
Rename isFunctionOrPoly to isFunctionType
This method checks if the type is any kind of function type: `FunctionN`, `ContextFunctionN`, `PolyFunction`, and `ErasedFunction`.
1 parent c03d69f commit d7167b0

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class CheckCaptures extends Recheck, SymTransformer:
187187
capt.println(i"solving $t")
188188
refs.solve()
189189
traverse(parent)
190-
case t @ RefinedType(_, nme.apply, rinfo) if defn.isFunctionOrPolyType(t) =>
190+
case t @ RefinedType(_, nme.apply, rinfo) if defn.isFunctionType(t) =>
191191
traverse(rinfo)
192192
case tp: TypeVar =>
193193
case tp: TypeRef =>
@@ -769,7 +769,7 @@ class CheckCaptures extends Recheck, SymTransformer:
769769
case actual @ AppliedType(tycon, args) if defn.isNonRefinedFunction(actual) =>
770770
adaptFun(actual, args.init, args.last, expected, covariant, insertBox,
771771
(aargs1, ares1) => actual.derivedAppliedType(tycon, aargs1 :+ ares1))
772-
case actual @ RefinedType(_, _, rinfo: MethodType) if defn.isFunctionOrPolyType(actual) =>
772+
case actual @ RefinedType(_, _, rinfo: MethodType) if defn.isFunctionType(actual) =>
773773
// TODO Find a way to combine handling of generic and dependent function types (here and elsewhere)
774774
adaptFun(actual, rinfo.paramInfos, rinfo.resType, expected, covariant, insertBox,
775775
(aargs1, ares1) =>
@@ -779,7 +779,7 @@ class CheckCaptures extends Recheck, SymTransformer:
779779
adaptFun(actual, actual.paramInfos, actual.resType, expected, covariant, insertBox,
780780
(aargs1, ares1) =>
781781
actual.derivedLambdaType(paramInfos = aargs1, resType = ares1))
782-
case actual @ RefinedType(p, nme, rinfo: PolyType) if defn.isFunctionOrPolyType(actual) =>
782+
case actual @ RefinedType(p, nme, rinfo: PolyType) if defn.isFunctionType(actual) =>
783783
adaptTypeFun(actual, rinfo.resType, expected, covariant, insertBox,
784784
ares1 =>
785785
val rinfo1 = rinfo.derivedLambdaType(rinfo.paramNames, rinfo.paramInfos, ares1)
@@ -996,7 +996,7 @@ class CheckCaptures extends Recheck, SymTransformer:
996996
case CapturingType(parent, refs) =>
997997
healCaptureSet(refs)
998998
traverse(parent)
999-
case tp @ RefinedType(parent, rname, rinfo: MethodType) if defn.isFunctionOrPolyType(tp) =>
999+
case tp @ RefinedType(parent, rname, rinfo: MethodType) if defn.isFunctionType(tp) =>
10001000
traverse(rinfo)
10011001
case tp: TermLambda =>
10021002
val saved = allowed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extends tpd.TreeTraverser:
5454
val boxedRes = recur(res)
5555
if boxedRes eq res then tp
5656
else tp1.derivedAppliedType(tycon, args.init :+ boxedRes)
57-
case tp1 @ RefinedType(_, _, rinfo: MethodType) if defn.isFunctionOrPolyType(tp1) =>
57+
case tp1 @ RefinedType(_, _, rinfo: MethodType) if defn.isFunctionType(tp1) =>
5858
val boxedRinfo = recur(rinfo)
5959
if boxedRinfo eq rinfo then tp
6060
else boxedRinfo.toFunctionType(isJava = false, alwaysDependent = true)
@@ -231,7 +231,7 @@ extends tpd.TreeTraverser:
231231
tp.derivedAppliedType(tycon1, args1 :+ res1)
232232
else
233233
tp.derivedAppliedType(tycon1, args.mapConserve(arg => this(arg)))
234-
case tp @ RefinedType(core, rname, rinfo: MethodType) if defn.isFunctionOrPolyType(tp) =>
234+
case tp @ RefinedType(core, rname, rinfo: MethodType) if defn.isFunctionType(tp) =>
235235
val rinfo1 = apply(rinfo)
236236
if rinfo1 ne rinfo then rinfo1.toFunctionType(isJava = false, alwaysDependent = true)
237237
else tp
@@ -329,7 +329,7 @@ extends tpd.TreeTraverser:
329329
args.last, CaptureSet.empty, currentCs ++ outerCs)
330330
tp.derivedAppliedType(tycon1, args1 :+ resType1)
331331
tp1.capturing(outerCs)
332-
case tp @ RefinedType(parent, nme.apply, rinfo: MethodType) if defn.isFunctionOrPolyType(tp) =>
332+
case tp @ RefinedType(parent, nme.apply, rinfo: MethodType) if defn.isFunctionType(tp) =>
333333
propagateDepFunctionResult(mapOver(tp), currentCs ++ outerCs)
334334
.capturing(outerCs)
335335
case _ =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ class Definitions {
17261726
* - ErasedFunction
17271727
* - PolyFunction
17281728
*/
1729-
def isFunctionOrPolyType(tp: Type)(using Context): Boolean =
1729+
def isFunctionType(tp: Type)(using Context): Boolean =
17301730
isFunctionNType(tp) || isRefinedFunctionType(tp)
17311731

17321732
private def withSpecMethods(cls: ClassSymbol, bases: List[Name], paramTypes: Set[TypeRef]) =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4073,7 +4073,7 @@ object Types {
40734073
tp.derivedAppliedType(tycon, addInto(args.head) :: Nil)
40744074
case tp @ AppliedType(tycon, args) if defn.isFunctionNType(tp) =>
40754075
wrapConvertible(tp.derivedAppliedType(tycon, args.init :+ addInto(args.last)))
4076-
case tp @ RefinedType(parent, rname, rinfo) if defn.isFunctionOrPolyType(tp) =>
4076+
case tp @ RefinedType(parent, rname, rinfo) if defn.isFunctionType(tp) =>
40774077
wrapConvertible(tp.derivedRefinedType(parent, rname, addInto(rinfo)))
40784078
case tp: MethodOrPoly =>
40794079
tp.derivedLambdaType(resType = addInto(tp.resType))

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
266266
if !printDebug && appliedText(tp.asInstanceOf[HKLambda].resType).isEmpty =>
267267
// don't eta contract if the application would be printed specially
268268
toText(tycon)
269-
case tp: RefinedType if defn.isFunctionOrPolyType(tp) && !printDebug =>
269+
case tp: RefinedType if defn.isFunctionType(tp) && !printDebug =>
270270
toTextMethodAsFunction(tp.refinedInfo,
271271
isPure = Feature.pureFunsEnabled && !tp.typeSymbol.name.isImpureFunction)
272272
case tp: TypeRef =>
@@ -771,7 +771,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
771771
override protected def toTextCapturing(tp: Type, refsText: Text, boxText: Text): Text = tp match
772772
case tp: AppliedType if defn.isFunctionSymbol(tp.typeSymbol) && !printDebug =>
773773
boxText ~ toTextFunction(tp, refsText)
774-
case tp: RefinedType if defn.isFunctionOrPolyType(tp) && !printDebug =>
774+
case tp: RefinedType if defn.isFunctionType(tp) && !printDebug =>
775775
boxText ~ toTextMethodAsFunction(tp.refinedInfo, isPure = !tp.typeSymbol.name.isImpureFunction, refsText)
776776
case _ =>
777777
super.toTextCapturing(tp, refsText, boxText)

0 commit comments

Comments
 (0)