Skip to content

Commit

Permalink
Merge pull request scalamacros#99 from xeno-by/master
Browse files Browse the repository at this point in the history
  • Loading branch information
xeno-by authored Oct 19, 2016
2 parents e509043 + eee78e7 commit cc7acde
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,11 @@ class LogicalTrees[G <: Global](val global: G, root: G#Tree) extends ReflectTool
// ============ PKGS ============

object PackageDef {
def unapply(tree: g.PackageDef): Option[(l.TermName, List[g.Tree])] = {
def unapply(tree: g.PackageDef): Option[(g.Tree, List[g.Tree])] = {
require(tree.pid.name != nme.EMPTY_PACKAGE_NAME)
val lpid = tree.pid
val lstats = toplevelStats(tree.stats)
Some((l.TermName(tree.pid), lstats))
Some((lpid, lstats))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ trait ToMtree { self: Converter =>

// ============ PKGS ============

case l.PackageDef(lname, lstats) =>
val mname = lname.toMtree[m.Term.Name]
case l.PackageDef(lref, lstats) =>
val mref = lref.toMtree[m.Term.Ref]
val mstats = lstats.toMtrees[m.Stat]
m.Pkg(mname, mstats)
m.Pkg(mref, mstats)

// ============ CTORS ============

Expand Down Expand Up @@ -533,9 +533,11 @@ trait ToMtree { self: Converter =>
case g.PackageDef(g.Ident(g.nme.EMPTY_PACKAGE_NAME), gstats) =>
val mstats = gstats.toMtrees[m.Stat]
m.Source(mstats)
case g.PackageDef(_, _) =>
case g.PackageDef(_, _) if classTag[T].runtimeClass == classOf[m.Source] =>
val mstats = List(gtree.toMtree[m.Pkg])
m.Source(mstats)
case g.PackageDef(_, _) =>
gtree.toMtree[m.Pkg]
case _ =>
gtree.toMtree[T]
}
Expand Down
2 changes: 1 addition & 1 deletion tests/converter/src/test/scala/Syntactic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,5 @@ class Syntactic extends ConverterSuite {
""")
syntactic("def add(a: Int)(implicit z: Int = 0) = a + z")
syntactic("def f(x: => T) = ???")

syntactic("package a.b { }")
}

0 comments on commit cc7acde

Please sign in to comment.