Skip to content

Commit 9e88458

Browse files
committed
Remove FunctionRefinementOf
1 parent cfe4fcf commit 9e88458

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,23 +1193,12 @@ class Definitions {
11931193
}
11941194

11951195
object DependentFunctionRefinementOf {
1196-
/** Matches a refined function type and extracts the function type and apply info.
1196+
/** Matches a refined `FunctionN[...]` or `ContextFunctionN[...]` type and extracts the function type and apply info.
11971197
*
11981198
* Pattern: `$ft { def apply: $mt }`
11991199
*/
12001200
def unapply(ft: Type)(using Context): Option[(Type, MethodType)] = ft.dealias match
1201-
case FunctionRefinementOf(parent, mt: MethodType) if !parent.derivesFrom(PolyFunctionClass) =>
1202-
Some((parent, mt))
1203-
case _ => None
1204-
}
1205-
1206-
object FunctionRefinementOf {
1207-
/** Matches a refined function type or PolyFunction and extracts the function type and apply info.
1208-
*
1209-
* Pattern: `$ft { def apply: $mt }`
1210-
*/
1211-
def unapply(ft: Type)(using Context): Option[(Type, MethodType)] = ft.dealias match
1212-
case RefinedType(parent, nme.apply, mt: MethodType) if isFunctionType(parent) =>
1201+
case RefinedType(parent, nme.apply, mt: MethodType) if isFunctionNType(parent) =>
12131202
Some((parent, mt))
12141203
case _ => None
12151204
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
13211321
case tp: TypeParamRef =>
13221322
decomposeProtoFunction(ctx.typerState.constraint.entry(tp).bounds.hi, defaultArity, pos)
13231323
case _ => pt1.findFunctionType match {
1324-
case ft @ defn.FunctionRefinementOf(_, mt @ MethodTpe(_, formals, restpe)) =>
1324+
case ft @ defn.PolyFunctionOf(mt @ MethodTpe(_, formals, restpe)) =>
1325+
if formals.length != defaultArity then fallbackProto
1326+
else (formals, untpd.InLambdaTypeTree(isResult = true, (_, syms) => restpe.substParams(mt, syms.map(_.termRef))))
1327+
case ft @ defn.DependentFunctionRefinementOf(_, mt @ MethodTpe(_, formals, restpe)) =>
13251328
if formals.length != defaultArity then fallbackProto
13261329
else (formals, untpd.InLambdaTypeTree(isResult = true, (_, syms) => restpe.substParams(mt, syms.map(_.termRef))))
13271330
case ft @ defn.FunctionNOf(_, _, _) =>

0 commit comments

Comments
 (0)