Skip to content
Snippets Groups Projects
Commit 39e4e09d authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Rename UnapplyPattern.id -> fd

parent 9af0e9ad
Branches
Tags
No related merge requests found
...@@ -13,7 +13,7 @@ trait CallGraph { ...@@ -13,7 +13,7 @@ trait CallGraph {
private def collectCallsInPats(fd: FunDef)(p: Pattern): Set[(FunDef, FunDef)] = private def collectCallsInPats(fd: FunDef)(p: Pattern): Set[(FunDef, FunDef)] =
(p match { (p match {
case u: UnapplyPattern => Set((fd, symbols.getFunction(u.id))) case u: UnapplyPattern => Set((fd, symbols.getFunction(u.fd)))
case _ => Set() case _ => Set()
}) ++ p.subPatterns.flatMap(collectCallsInPats(fd)) }) ++ p.subPatterns.flatMap(collectCallsInPats(fd))
......
...@@ -272,9 +272,9 @@ trait Expressions { self: Trees => ...@@ -272,9 +272,9 @@ trait Expressions { self: Trees =>
} }
/** A custom pattern defined through an object's `unapply` function */ /** A custom pattern defined through an object's `unapply` function */
case class UnapplyPattern(binder: Option[ValDef], id: Identifier, tps: Seq[Type], subPatterns: Seq[Pattern]) extends Pattern { case class UnapplyPattern(binder: Option[ValDef], fd: Identifier, tps: Seq[Type], subPatterns: Seq[Pattern]) extends Pattern {
// Hacky, but ok // Hacky, but ok
def optionType(implicit s: Symbols) = s.getFunction(id, tps).returnType.asInstanceOf[ClassType] def optionType(implicit s: Symbols) = s.getFunction(fd, tps).returnType.asInstanceOf[ClassType]
def optionChildren(implicit s: Symbols): (ClassType, ClassType) = { def optionChildren(implicit s: Symbols): (ClassType, ClassType) = {
val children = optionType.tcd.asInstanceOf[TypedAbstractClassDef].descendants.sortBy(_.fields.size) val children = optionType.tcd.asInstanceOf[TypedAbstractClassDef].descendants.sortBy(_.fields.size)
val Seq(noneType, someType) = children.map(_.toType) val Seq(noneType, someType) = children.map(_.toType)
...@@ -297,7 +297,7 @@ trait Expressions { self: Trees => ...@@ -297,7 +297,7 @@ trait Expressions { self: Trees =>
val vd = ValDef(FreshIdentifier("unap", true), optionType) val vd = ValDef(FreshIdentifier("unap", true), optionType)
Let( Let(
vd, vd,
FunctionInvocation(id, tps, Seq(scrut)), FunctionInvocation(fd, tps, Seq(scrut)),
IfExpr( IfExpr(
IsInstanceOf(vd.toVariable, someType), IsInstanceOf(vd.toVariable, someType),
someCase(CaseClassSelector(someType, vd.toVariable, someValue.id)), someCase(CaseClassSelector(someType, vd.toVariable, someValue.id)),
...@@ -318,12 +318,12 @@ trait Expressions { self: Trees => ...@@ -318,12 +318,12 @@ trait Expressions { self: Trees =>
*/ */
def getUnsafe(scrut: Expr)(implicit s: Symbols) = CaseClassSelector( def getUnsafe(scrut: Expr)(implicit s: Symbols) = CaseClassSelector(
someType, someType,
FunctionInvocation(id, tps, Seq(scrut)), FunctionInvocation(fd, tps, Seq(scrut)),
someValue.id someValue.id
) )
def isSome(scrut: Expr)(implicit s: Symbols) = def isSome(scrut: Expr)(implicit s: Symbols) =
IsInstanceOf(FunctionInvocation(id, tps, Seq(scrut)), someType) IsInstanceOf(FunctionInvocation(fd, tps, Seq(scrut)), someType)
} }
// Extracts without taking care of the binder. (contrary to Extractos.Pattern) // Extracts without taking care of the binder. (contrary to Extractos.Pattern)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment