Skip to content

Commit

Permalink
Rename isNonRefinedFunction to isNonPolyFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jul 27, 2023
1 parent 749b07c commit 3856aa1
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/cc/CaptureSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ object CaptureSet:
++ (recur(rinfo.resType) // add capture set of result
-- CaptureSet(rinfo.paramRefs.filter(_.isTracked)*)) // but disregard bound parameters
case tpd @ AppliedType(tycon, args) =>
if followResult && defn.isNonRefinedFunction(tpd) then
if followResult && defn.isNonPolyFunction(tpd) then
recur(args.last)
// must be (pure) FunctionN type since ImpureFunctions have already
// been eliminated in selector's dealias. Use capture set of result.
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ class CheckCaptures extends Recheck, SymTransformer:
if eparent1 eq eparent then expected
else CapturingType(eparent1, refs, boxed = expected0.isBoxed)
case expected @ defn.FunctionOf(args, resultType, isContextual)
if defn.isNonRefinedFunction(expected) && defn.isFunctionNType(actual) && !defn.isNonRefinedFunction(actual) =>
if defn.isNonPolyFunction(expected) && defn.isFunctionNType(actual) && !defn.isNonPolyFunction(actual) =>
val expected1 = toDepFun(args, resultType, isContextual)
expected1
case _ =>
Expand Down Expand Up @@ -842,7 +842,7 @@ class CheckCaptures extends Recheck, SymTransformer:

// Adapt the inner shape type: get the adapted shape type, and the capture set leaked during adaptation
val (styp1, leaked) = styp match {
case actual @ AppliedType(tycon, args) if defn.isNonRefinedFunction(actual) =>
case actual @ AppliedType(tycon, args) if defn.isNonPolyFunction(actual) =>
adaptFun(actual, args.init, args.last, expected, covariant, insertBox,
(aargs1, ares1) => actual.derivedAppliedType(tycon, aargs1 :+ ares1))
case actual @ RefinedType(_, _, rinfo: MethodType) if defn.isFunctionType(actual) =>
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/cc/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extends tpd.TreeTraverser:
def recur(tp: Type): Type = tp.dealias match
case tp @ CapturingType(parent, refs) if !tp.isBoxed =>
tp.boxed
case tp1 @ AppliedType(tycon, args) if defn.isNonRefinedFunction(tp1) =>
case tp1 @ AppliedType(tycon, args) if defn.isNonPolyFunction(tp1) =>
val res = args.last
val boxedRes = recur(res)
if boxedRes eq res then tp
Expand Down Expand Up @@ -129,7 +129,7 @@ extends tpd.TreeTraverser:
apply(parent)
case tp @ AppliedType(tycon, args) =>
val tycon1 = this(tycon)
if defn.isNonRefinedFunction(tp) then
if defn.isNonPolyFunction(tp) then
// Convert toplevel generic function types to dependent functions
if !defn.isFunctionSymbol(tp.typeSymbol) && (tp.dealias ne tp) then
// This type is a function after dealiasing, so we dealias and recurse.
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ class Definitions {
/** Is `tp` (an alias) of either a scala.FunctionN or a scala.ContextFunctionN
* instance?
*/
def isNonRefinedFunction(tp: Type)(using Context): Boolean =
def isNonPolyFunction(tp: Type)(using Context): Boolean =
val arity = functionArity(tp)
val sym = tp.dealias.typeSymbol

Expand All @@ -1728,14 +1728,14 @@ class Definitions {
&& tp.isRef(
FunctionType(arity, sym.name.isContextFunction).typeSymbol,
skipRefined = false)
end isNonRefinedFunction
end isNonPolyFunction

/** Returns whether `tp` is an instance or a refined instance of:
* - scala.FunctionN
* - scala.ContextFunctionN
*/
def isFunctionNType(tp: Type)(using Context): Boolean =
isNonRefinedFunction(tp.dropDependentRefinement)
isNonPolyFunction(tp.dropDependentRefinement)

/** Returns whether `tp` is an instance or a refined instance of:
* - scala.FunctionN
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ object Types {

/** Dealias, and if result is a dependent function type, drop the `apply` refinement. */
final def dropDependentRefinement(using Context): Type = dealias match {
case RefinedType(parent, nme.apply, mt) if defn.isNonRefinedFunction(parent) => parent
case RefinedType(parent, nme.apply, mt) if defn.isNonPolyFunction(parent) => parent
case tp => tp
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ class Namer { typer: Typer =>
val approxTp = wildApprox(originalTp)
approxTp.stripPoly match
case atp @ defn.ContextFunctionType(_, resType, _)
if !defn.isNonRefinedFunction(atp) // in this case `resType` is lying, gives us only the non-dependent upper bound
if !defn.isNonPolyFunction(atp) // in this case `resType` is lying, gives us only the non-dependent upper bound
|| resType.existsPart(_.isInstanceOf[WildcardType], StopAt.Static, forceLazy = false) =>
originalTp
case _ =>
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1320,14 +1320,14 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
case tp: TypeParamRef =>
decomposeProtoFunction(ctx.typerState.constraint.entry(tp).bounds.hi, defaultArity, pos)
case _ => pt1.findFunctionType match {
case pt1 if defn.isNonRefinedFunction(pt1) =>
case pt1 if defn.isNonPolyFunction(pt1) =>
// if expected parameter type(s) are wildcards, approximate from below.
// if expected result type is a wildcard, approximate from above.
// this can type the greatest set of admissible closures.

(pt1.argInfos.init, typeTree(interpolateWildcards(pt1.argInfos.last.hiBound)))
case RefinedType(parent, nme.apply, mt @ MethodTpe(_, formals, restpe))
if defn.isNonRefinedFunction(parent) && formals.length == defaultArity =>
if defn.isNonPolyFunction(parent) && formals.length == defaultArity =>
(formals, untpd.InLambdaTypeTree(isResult = true, (_, syms) => restpe.substParams(mt, syms.map(_.termRef))))
case defn.PolyFunctionOf(mt @ MethodTpe(_, formals, restpe)) if formals.length == defaultArity =>
(formals, untpd.InLambdaTypeTree(isResult = true, (_, syms) => restpe.substParams(mt, syms.map(_.termRef))))
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
def isDependentFunctionType: Boolean =
val tpNoRefinement = self.dropDependentRefinement
tpNoRefinement != self
&& dotc.core.Symbols.defn.isNonRefinedFunction(tpNoRefinement)
&& dotc.core.Symbols.defn.isNonPolyFunction(tpNoRefinement)
def isTupleN: Boolean =
dotc.core.Symbols.defn.isTupleNType(self)
def select(sym: Symbol): TypeRepr = self.select(sym)
Expand Down

0 comments on commit 3856aa1

Please sign in to comment.