Skip to content

Fix printing binded alternatives #4704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions library/src/scala/tasty/util/ShowSourceCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,9 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
this += ")"

case Pattern.Alternative(trees) =>
this += "("
printPatterns(trees, " | ")
this += ")"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduce a verb inParens { ... }?


case Pattern.TypeTest(tpt) =>
this += "_: "
Expand Down
17 changes: 17 additions & 0 deletions tests/run/virtpatmat_alts.decompiled
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** Decompiled from out/runTestFromTasty/run/virtpatmat_alts/Test.class */
object Test extends dotty.runtime.LegacyApp() {
scala.Tuple2.apply[scala.Boolean, scala.Boolean](true, true) match {
case (scala.Tuple2(true, true) | scala.Tuple2(false, false)) =>
1
}
scala.List.apply[scala.Int](5) match {
case (scala.::(1, scala.Nil) | scala.::(2, scala.Nil)) =>
scala.Predef.println("FAILED")
case scala.::(x @ (4 | 5 | 6), scala.Nil) =>
scala.Predef.println("OK ".+(x))
case scala.::(7, scala.Nil) =>
scala.Predef.println("FAILED")
case scala.Nil =>
scala.Predef.println("FAILED")
}
}