Skip to content

Commit

Permalink
Use more precise return types for objects
Browse files Browse the repository at this point in the history
This ensures that q"object O" is of type ModuleDef rather than
Tree and similarly q"package object O" is of type PackageDef.
  • Loading branch information
densh committed Jan 24, 2014
1 parent 36885b0 commit fdce4a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/reflect/scala/reflect/api/BuildUtils.scala
Expand Up @@ -145,15 +145,15 @@ private[reflect] trait BuildUtils { self: Universe =>

trait SyntacticObjectDefExtractor {
def apply(mods: Modifiers, name: TermName, earlyDefs: List[Tree],
parents: List[Tree], selfType: Tree, body: List[Tree]): Tree
parents: List[Tree], selfType: Tree, body: List[Tree]): ModuleDef
def unapply(tree: Tree): Option[(Modifiers, TermName, List[Tree], List[Tree], ValDef, List[Tree])]
}

val SyntacticPackageObjectDef: SyntacticPackageObjectDefExtractor

trait SyntacticPackageObjectDefExtractor {
def apply(name: TermName, earlyDefs: List[Tree],
parents: List[Tree], selfType: Tree, body: List[Tree]): Tree
parents: List[Tree], selfType: Tree, body: List[Tree]): PackageDef
def unapply(tree: Tree): Option[(TermName, List[Tree], List[Tree], ValDef, List[Tree])]
}

Expand Down
4 changes: 2 additions & 2 deletions src/reflect/scala/reflect/internal/BuildUtils.scala
Expand Up @@ -289,7 +289,7 @@ trait BuildUtils { self: SymbolTable =>

object SyntacticObjectDef extends SyntacticObjectDefExtractor {
def apply(mods: Modifiers, name: TermName, earlyDefs: List[Tree],
parents: List[Tree], selfType: Tree, body: List[Tree]) =
parents: List[Tree], selfType: Tree, body: List[Tree]): ModuleDef =
ModuleDef(mods, name, gen.mkTemplate(parents, mkSelfType(selfType), NoMods, Nil, earlyDefs ::: body))

def unapply(tree: Tree): Option[(Modifiers, TermName, List[Tree], List[Tree], ValDef, List[Tree])] = tree match {
Expand All @@ -302,7 +302,7 @@ trait BuildUtils { self: SymbolTable =>

object SyntacticPackageObjectDef extends SyntacticPackageObjectDefExtractor {
def apply(name: TermName, earlyDefs: List[Tree],
parents: List[Tree], selfType: Tree, body: List[Tree]): Tree =
parents: List[Tree], selfType: Tree, body: List[Tree]): PackageDef =
gen.mkPackageObject(SyntacticObjectDef(NoMods, name, earlyDefs, parents, selfType, body))

def unapply(tree: Tree): Option[(TermName, List[Tree], List[Tree], ValDef, List[Tree])] = tree match {
Expand Down

0 comments on commit fdce4a0

Please sign in to comment.