Skip to content

Commit 171773d

Browse files
committed
Simplify defn.FunctionOf.unapply
1 parent e4ba788 commit 171773d

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ class CheckCaptures extends Recheck, SymTransformer:
459459
else if meth == defn.Caps_unsafeUnbox then
460460
mapArgUsing(_.forceBoxStatus(false))
461461
else if meth == defn.Caps_unsafeBoxFunArg then
462-
def forceBox(tp: Type): Type = tp match
462+
def forceBox(tp: Type): Type = tp.strippedDealias match
463463
case defn.FunctionOf(paramtpe :: Nil, restpe, isContextual) =>
464464
defn.FunctionOf(paramtpe.forceBoxStatus(true) :: Nil, restpe, isContextual)
465465
case tp @ RefinedType(parent, rname, rinfo: MethodType) =>

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,16 +1143,13 @@ class Definitions {
11431143
else FunctionNOf(args, resultType, isContextual)
11441144

11451145
def unapply(ft: Type)(using Context): Option[(List[Type], Type, Boolean)] = {
1146-
ft.dealias match
1146+
ft match
11471147
case PolyFunctionOf(mt: MethodType) =>
11481148
Some(mt.paramInfos, mt.resType, mt.isContextualMethod)
1149-
case dft =>
1150-
val tsym = dft.typeSymbol
1151-
if isFunctionSymbol(tsym) && ft.isRef(tsym) then
1152-
val targs = dft.argInfos
1153-
if (targs.isEmpty) None
1154-
else Some(targs.init, targs.last, tsym.name.isContextFunction)
1155-
else None
1149+
case AppliedType(parent, targs) if isFunctionNType(ft) =>
1150+
Some(targs.init, targs.last, ft.typeSymbol.name.isContextFunction)
1151+
case _ =>
1152+
None
11561153
}
11571154
}
11581155

compiler/src/dotty/tools/dotc/transform/Recheck.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ object Recheck:
104104
* - in function and method parameter types
105105
* - under annotations
106106
*/
107-
def normalizeByName(tp: Type)(using Context): Type = tp match
107+
def normalizeByName(tp: Type)(using Context): Type = tp.dealias match
108108
case tp: ExprType =>
109109
mapExprType(tp)
110110
case tp: PolyType =>

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,10 +2003,7 @@ trait Applications extends Compatibility {
20032003
// the arity of that function, otherise -1.
20042004
def paramCount(ref: TermRef) =
20052005
val formals = ref.widen.firstParamTypes
2006-
if formals.length > idx then
2007-
formals(idx).dealias match
2008-
case defn.FunctionNOf(args, _, _) => args.length
2009-
case _ => -1
2006+
if formals.length > idx then defn.functionArity(formals(idx))
20102007
else -1
20112008

20122009
val numArgs = args.length

0 commit comments

Comments
 (0)