We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Repeated arguments (foo(xs: _*)) can either be Seq or Array (Scala 2.13 deprecates passing Array to Scala methods taking repeated arguments, but allows passing both Array and Seq to Java methods, Dotty doesn't implement that deprecation currently). But quoted patterns assume that a repeated argument is a Seq: https://github.com/lampepfl/dotty/blob/588ac1b9252802e118d080dae86f7c3756dbfee6/compiler/src/dotty/tools/dotc/typer/Typer.scala#L730
foo(xs: _*)
import scala.quoted._ object Macros { inline def testSeq(): Any = ${impl('{java.util.Arrays.asList[Int](Seq(1): _*)})} inline def testArray(): Any = ${impl('{java.util.Arrays.asList[Int](Array(1): _*)})} private def impl(expr: Expr[Any])(using QuoteContext): Expr[Any] = expr match { case '{ java.util.Arrays.asList[$t]($xs: _*) } => xs case _ => '{ "FAIL" } } }
import Macros._ object Test { def main(args: Array[String]): Unit = { println(testSeq()) // "List(1)" println(testArray()) // "FAIL" } }
The text was updated successfully, but these errors were encountered:
(note that I have an open PR which interacts with this code which is how I found this: #8669)
Sorry, something went wrong.
Fix scala#8680: Match array in varargs
0f0fa70
Return them as sequences
nicolasstucki
No branches or pull requests
Repeated arguments (
foo(xs: _*)
) can either be Seq or Array (Scala 2.13 deprecates passing Array to Scala methods taking repeated arguments, but allows passing both Array and Seq to Java methods, Dotty doesn't implement that deprecation currently). But quoted patterns assume that a repeated argument is a Seq:https://github.com/lampepfl/dotty/blob/588ac1b9252802e118d080dae86f7c3756dbfee6/compiler/src/dotty/tools/dotc/typer/Typer.scala#L730
The text was updated successfully, but these errors were encountered: