Skip to content

Commit

Permalink
Merge pull request #45 from JBakouny/master
Browse files Browse the repository at this point in the history
A fix for issue #44: case classes with an empty parameter list should be printed with parenthesis
  • Loading branch information
eed3si9n authored Jul 6, 2018
2 parents 0cee96f + 0ab53f9 commit 07e0bc9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion library/src/main/scala/treehugger/TreePrinters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package treehugger

import java.io.{ OutputStream, PrintWriter, StringWriter, Writer }
import Flags._
import treehugger.api.Modifier

trait TreePrinters extends api.TreePrinters { self: Forest =>

Expand Down Expand Up @@ -309,7 +310,8 @@ trait TreePrinters extends api.TreePrinters { self: Forest =>
print(" ")
printModifiers(tree, ctormods)
}
if (vparams != Nil) printValueParams(vparams, true)
if (vparams != Nil || modifiersOfFlags(mods.flags).contains(Modifier.`case`))
printValueParams(vparams, true)

print(if (mods.isDeferred) " <: "
else if (impl.parents.isEmpty) ""
Expand Down
2 changes: 1 addition & 1 deletion library/src/test/scala/DSL_2ClassSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ sealed classes `withFlags(Flags.SEALED)`. $c
)

def caseclass1 =
((CASECLASSDEF("C"): Tree) must print_as("case class C")) and
((CASECLASSDEF("C"): Tree) must print_as("case class C()")) and
((CASECLASSDEF("C") withParams(VAL("x", IntClass) withFlags(Flags.OVERRIDE)) withParents(sym.Addressable APPLY(REF("x"))) := BLOCK(
DEF("y") := LIT(0)
))
Expand Down

0 comments on commit 07e0bc9

Please sign in to comment.