Skip to content

Commit

Permalink
Simplify defn.FunctionOf.unapply
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Aug 30, 2023
1 parent c58f9f6 commit 91615cb
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1116,16 +1116,13 @@ class Definitions {
else
FunctionType(args.length, isContextual).appliedTo(args ::: resultType :: Nil)
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 targs.nonEmpty && isFunctionNType(ft) =>
Some(targs.init, targs.last, ft.typeSymbol.name.isContextFunction)
case _ =>
None
}
}

Expand Down

0 comments on commit 91615cb

Please sign in to comment.