Skip to content

Fix #7395: Handle inlined repeated arguments #7398

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
Oct 9, 2019
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
8 changes: 3 additions & 5 deletions library/src/scala/tasty/reflect/Printers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -833,12 +833,10 @@ trait Printers
case Typed(term, tpt) =>
tpt.tpe match {
case Types.Repeated(_) =>
printTree(term)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The term contains the argument sequence

term match {
case Repeated(_, _) =>
printTree(term)
case _ =>
printTree(term)
this += ": " += highlightTypeDef("_*")
case Repeated(_, _) | Inlined(None, Nil, Repeated(_, _)) => this
case _ => this += ": " += highlightTypeDef("_*")
}
case _ =>
inParens {
Expand Down
4 changes: 2 additions & 2 deletions tests/run-macros/i6765-b.check
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scala.List.apply[java.lang.String]("One": _*)
scala.List.apply[java.lang.String]("One": _*)
scala.List.apply[java.lang.String]("One")
scala.List.apply[java.lang.String]("One")
10 changes: 5 additions & 5 deletions tests/run-macros/i6765-c.check
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
scala.Nil
List()

scala.List.apply[java.lang.String]("#0": _*)
scala.List.apply[java.lang.String]("#0")
List(#0)

scala.List.apply[java.lang.String]("#0", "#1": _*)
scala.List.apply[java.lang.String]("#0", "#1")
List(#0, #1)

scala.List.apply[java.lang.String]("#0", "#1", "#2": _*)
scala.List.apply[java.lang.String]("#0", "#1", "#2")
List(#0, #1, #2)

scala.List.apply[java.lang.String]("#0", "#1", "#2", "#3": _*)
scala.List.apply[java.lang.String]("#0", "#1", "#2", "#3")
List(#0, #1, #2, #3)

scala.List.apply[java.lang.String]("#0", "#1", "#2", "#3", "#4": _*)
scala.List.apply[java.lang.String]("#0", "#1", "#2", "#3", "#4")
List(#0, #1, #2, #3, #4)

4 changes: 2 additions & 2 deletions tests/run-macros/i6765.check
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scala.List.apply[java.lang.String]("One": _*)
scala.List.apply[java.lang.String]("One": _*)
scala.List.apply[java.lang.String]("One")
scala.List.apply[java.lang.String]("One")
1 change: 1 addition & 0 deletions tests/run-staging/i7381.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scala.List.apply[scala.Int](1, 2, 3)
14 changes: 14 additions & 0 deletions tests/run-staging/i7381.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import scala.quoted._
import scala.quoted.staging._

object Test {

def main(args: Array[String]): Unit = {
given Toolbox = Toolbox.make(getClass.getClassLoader)
withQuoteContext {
val expr = Expr(List(1, 2, 3))
println(expr.show)
}
}

}