Skip to content

Commit bbd8d81

Browse files
committed
Optimize FunctionNOf.unapply
1 parent d78c157 commit bbd8d81

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,13 +1136,10 @@ class Definitions {
11361136
/** Matches a (possibly aliased) `FunctionN[...]` or `ContextFunctionN[...]`.
11371137
* Extracts the list of function argument types, the result type and whether function is contextual.
11381138
*/
1139-
def unapply(tpe: Type)(using Context): Option[(List[Type], Type, Boolean)] = {
1140-
val tsym = tpe.typeSymbol
1141-
if isFunctionSymbol(tsym) && tpe.isRef(tsym) then
1142-
val targs = tpe.argInfos
1143-
if (targs.isEmpty) None
1144-
else Some(targs.init, targs.last, tsym.name.isContextFunction)
1145-
else None
1139+
def unapply(tpe: AppliedType)(using Context): Option[(List[Type], Type, Boolean)] = {
1140+
val targs = tpe.args
1141+
if targs.isEmpty || !isFunctionNType(tpe) then None
1142+
else Some(targs.init, targs.last, tpe.typeSymbol.name.isContextFunction)
11461143
}
11471144
}
11481145

0 commit comments

Comments
 (0)