Skip to content

Commit

Permalink
Use more specific return type for SyntacticFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
densh committed Feb 7, 2014
1 parent 947baf2 commit 31c5310
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/reflect/scala/reflect/api/BuildUtils.scala
Expand Up @@ -198,9 +198,9 @@ private[reflect] trait BuildUtils { self: Universe =>
val SyntacticFunction: SyntacticFunctionExtractor

trait SyntacticFunctionExtractor {
def apply(params: List[Tree], body: Tree): Tree
def apply(params: List[Tree], body: Tree): Function

def unapply(tree: Tree): Option[(List[ValDef], Tree)]
def unapply(tree: Function): Option[(List[ValDef], Tree)]
}

val SyntacticDefDef: SyntacticDefDefExtractor
Expand Down
7 changes: 2 additions & 5 deletions src/reflect/scala/reflect/internal/BuildUtils.scala
Expand Up @@ -435,16 +435,13 @@ trait BuildUtils { self: SymbolTable =>
}

object SyntacticFunction extends SyntacticFunctionExtractor {
def apply(params: List[Tree], body: Tree): Tree = {
def apply(params: List[Tree], body: Tree): Function = {
val params0 :: Nil = mkParam(params :: Nil, PARAM)
require(params0.forall { _.rhs.isEmpty }, "anonymous functions don't support parameters with default values")
Function(params0, body)
}

def unapply(tree: Tree): Option[(List[ValDef], Tree)] = tree match {
case Function(params, body) => Some((params, body))
case _ => None
}
def unapply(tree: Function): Option[(List[ValDef], Tree)] = Function.unapply(tree)
}

object SyntacticNew extends SyntacticNewExtractor {
Expand Down

0 comments on commit 31c5310

Please sign in to comment.