Skip to content

Commit 83caec9

Browse files
committed
Inline FunctionOf in FunctionTypeOfMethod and optimize
1 parent f8c2b6d commit 83caec9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,10 +1117,14 @@ class Definitions {
11171117
case RefinedType(parent, nme.apply, mt: MethodOrPoly)
11181118
if parent.derivesFrom(defn.PolyFunctionClass) || isFunctionNType(parent) =>
11191119
Some(mt)
1120-
case FunctionOf(argTypes, resultType, isContextual) =>
1121-
val methodType = if isContextual then ContextualMethodType else MethodType
1122-
Some(methodType(argTypes, resultType))
1123-
case _ => None
1120+
case _ =>
1121+
val tsym = ft.typeSymbol
1122+
val targs = ft.argInfos
1123+
if targs.nonEmpty && isFunctionSymbol(tsym) && ft.isRef(tsym) then
1124+
val isContextual = tsym.name.isContextFunction
1125+
val methodType = if isContextual then ContextualMethodType else MethodType
1126+
Some(methodType(targs.init, targs.last))
1127+
else None
11241128
}
11251129
}
11261130

0 commit comments

Comments
 (0)