Skip to content

Commit fa0c231

Browse files
committed
Optimize FunctionTypeOfMethod
1 parent cef3bdc commit fa0c231

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,14 +1117,12 @@ class Definitions {
11171117
case RefinedType(parent, nme.apply, mt: MethodOrPoly)
11181118
if parent.derivesFrom(defn.PolyFunctionClass) || isFunctionNType(parent) =>
11191119
Some(mt)
1120+
case AppliedType(parent, targs) if targs.nonEmpty && isFunctionNType(ft) =>
1121+
val isContextual = ft.typeSymbol.name.isContextFunction
1122+
val methodType = if isContextual then ContextualMethodType else MethodType
1123+
Some(methodType(targs.init, targs.last))
11201124
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
1125+
None
11281126
}
11291127
}
11301128

0 commit comments

Comments
 (0)