diff --git a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala index a49bd9f79351..d6a03667311a 100644 --- a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala +++ b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala @@ -459,7 +459,7 @@ class CheckCaptures extends Recheck, SymTransformer: else if meth == defn.Caps_unsafeUnbox then mapArgUsing(_.forceBoxStatus(false)) else if meth == defn.Caps_unsafeBoxFunArg then - def forceBox(tp: Type): Type = tp match + def forceBox(tp: Type): Type = tp.strippedDealias match case defn.FunctionOf(paramtpe :: Nil, restpe, isContextual) => defn.FunctionOf(paramtpe.forceBoxStatus(true) :: Nil, restpe, isContextual) case tp @ RefinedType(parent, rname, rinfo: MethodType) => diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index dd92687262de..070a71e8f671 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -1143,16 +1143,13 @@ class Definitions { else FunctionNOf(args, resultType, isContextual) def unapply(ft: Type)(using Context): Option[(List[Type], Type, Boolean)] = { - ft.dealias match + ft match case PolyFunctionOf(mt: MethodType) => Some(mt.paramInfos, mt.resType, mt.isContextualMethod) - case dft => - val tsym = dft.typeSymbol - if isFunctionSymbol(tsym) && ft.isRef(tsym) then - val targs = dft.argInfos - if (targs.isEmpty) None - else Some(targs.init, targs.last, tsym.name.isContextFunction) - else None + case AppliedType(parent, targs) if isFunctionNType(ft) => + Some(targs.init, targs.last, ft.typeSymbol.name.isContextFunction) + case _ => + None } } diff --git a/compiler/src/dotty/tools/dotc/transform/Recheck.scala b/compiler/src/dotty/tools/dotc/transform/Recheck.scala index b15a58b98b6f..def0f1e1b98f 100644 --- a/compiler/src/dotty/tools/dotc/transform/Recheck.scala +++ b/compiler/src/dotty/tools/dotc/transform/Recheck.scala @@ -104,7 +104,7 @@ object Recheck: * - in function and method parameter types * - under annotations */ - def normalizeByName(tp: Type)(using Context): Type = tp match + def normalizeByName(tp: Type)(using Context): Type = tp.dealias match case tp: ExprType => mapExprType(tp) case tp: PolyType => diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 62cef94330c1..49c8910712c7 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -2003,10 +2003,7 @@ trait Applications extends Compatibility { // the arity of that function, otherise -1. def paramCount(ref: TermRef) = val formals = ref.widen.firstParamTypes - if formals.length > idx then - formals(idx).dealias match - case defn.FunctionNOf(args, _, _) => args.length - case _ => -1 + if formals.length > idx then defn.functionArity(formals(idx)) else -1 val numArgs = args.length