Skip to content

Commit 716c064

Browse files
committed
Add other missing parentheses
1 parent c5fb061 commit 716c064

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

library/src/scala/tasty/reflect/Printers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ trait Printers
809809
case Term.Apply(fn, args) =>
810810
fn match {
811811
case Term.Select(Term.This(_), "<init>") => this += "this" // call to constructor inside a constructor
812-
case _ => printTree(fn)
812+
case _ => printQualTree(fn)
813813
}
814814
val args1 = args match {
815815
case init :+ Term.Typed(Term.Repeated(Nil, _), _) => init // drop empty var args at the end
@@ -819,7 +819,7 @@ trait Printers
819819
inParens(printTrees(args1, ", "))
820820

821821
case Term.TypeApply(fn, args) =>
822-
printTree(fn)
822+
printQualTree(fn)
823823
fn match {
824824
case Term.Select(Term.New(TypeTree.Applied(_, _)), "<init>") =>
825825
// type bounds already printed in `fn`
@@ -894,7 +894,7 @@ trait Printers
894894
printTree(elsep)
895895

896896
case Term.Match(selector, cases) =>
897-
printTree(selector)
897+
printQualTree(selector)
898898
this += highlightKeyword(" match", color)
899899
inBlock(printCases(cases, lineBreak()))
900900

tests/pos/i5997.decompiled

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ class Test() {
77
}).map[scala.Int](((v: scala.Int) => v.+(1)))
88
val v4: java.lang.String = (while (true) ()).toString()
99
def v5: scala.Option[scala.Predef.String] = scala.Some.apply[java.lang.String]((return scala.Some.apply[java.lang.String]("a")).toString())
10+
def foo(x: scala.Boolean): scala.Boolean = x.unary_!
11+
def bar(): scala.Int = (if (true) 1 else 2) match {
12+
case x =>
13+
(x: scala.Int)
14+
}
15+
def baz(): scala.Any = (if (true) ((x: scala.Any) => scala.Predef.identity[scala.Any](x)) else ((x: scala.Any) => scala.Predef.identity[scala.Any](x))).apply(0)
1016
}

tests/pos/i5997.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ class Test {
44
val v3 = (1 match { case _ => Some(1) }).map(v => v+1)
55
val v4 = (while (true) ()).toString
66
def v5: Option[String] = Some((return Some("a")).toString)
7+
def foo(x: Boolean) = !x
8+
def bar() = (if true then 1 else 2) match { case x => x }
9+
def baz() = (if true then identity else identity)(0)
710
}

0 commit comments

Comments
 (0)