diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index fcd55cd71f8c..944712b6cd73 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -1136,13 +1136,10 @@ class Definitions { /** Matches a (possibly aliased) `FunctionN[...]` or `ContextFunctionN[...]`. * Extracts the list of function argument types, the result type and whether function is contextual. */ - def unapply(tpe: Type)(using Context): Option[(List[Type], Type, Boolean)] = { - val tsym = tpe.typeSymbol - if isFunctionSymbol(tsym) && tpe.isRef(tsym) then - val targs = tpe.argInfos - if (targs.isEmpty) None - else Some(targs.init, targs.last, tsym.name.isContextFunction) - else None + def unapply(tpe: AppliedType)(using Context): Option[(List[Type], Type, Boolean)] = { + val targs = tpe.args + if targs.isEmpty || !isFunctionNType(tpe) then None + else Some(targs.init, targs.last, tpe.typeSymbol.name.isContextFunction) } }