Skip to content

Commit

Permalink
SI-8875 showCode should print all class constructor modifiers.
Browse files Browse the repository at this point in the history
showCode used to print nothing when the only modifier was a change in
visibility scope (i.e. no flags but privateWithin is set).
  • Loading branch information
gourlaysama committed Oct 13, 2014
1 parent 2b5df37 commit ee5a5d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/internal/Printers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ trait Printers extends api.Printers { self: SymbolTable =>
val build.SyntacticClassDef(_, _, _, ctorMods, vparamss, earlyDefs, parents, selfType, body) = cl

// constructor's modifier
if (ctorMods.hasFlag(AccessFlags)) {
if (ctorMods.hasFlag(AccessFlags) || ctorMods.privateWithin != tpnme.EMPTY) {
print(" ")
printModifiers(ctorMods, primaryCtorParam = false)
}
Expand Down
7 changes: 7 additions & 0 deletions test/junit/scala/reflect/internal/PrintersTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ trait ClassPrintTests {
| def y = "test"
|}""")

@Test def testClassConstructorModifiers = assertPrintedCode("class X private (x: scala.Int)")

@Test def testClassConstructorModifierVisibility = assertPrintedCode(sm"""
|object A {
| class X protected[A] (x: scala.Int)
|}""")

@Test def testClassWithPublicParams = assertPrintedCode("class X(val x: scala.Int, val s: scala.Predef.String)")

@Test def testClassWithParams1 = assertPrintedCode("class X(x: scala.Int, s: scala.Predef.String)")
Expand Down

0 comments on commit ee5a5d1

Please sign in to comment.