From 5d1f0b473dee7883b58cc22f4b5b3b4476f82437 Mon Sep 17 00:00:00 2001 From: i10416 Date: Fri, 26 Jan 2024 04:30:36 +0900 Subject: [PATCH] tryfix(16459): workaround LARROW, but find a corner-case Confusing LARROW just after XML pattern breaks the parser. --- tests/run/i16459.scala | 51 +++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/tests/run/i16459.scala b/tests/run/i16459.scala index dd4cf14fbc88..909a0b3aa032 100644 --- a/tests/run/i16459.scala +++ b/tests/run/i16459.scala @@ -2,18 +2,12 @@ object Test { import scala.xml.* def main(args: Array[String]): Unit = { - val singleQuotedTextCase = if(true) { + val xml = if(true) { } else
empty
- - val casePatMatch = for (case t @ FooBar <- Seq(xml)) - yield t - // TODO: This fails - val casePatMatchWithCond = for (case t @ FooBar if true <- Seq(xml)) - yield t assert( xml match @@ -26,7 +20,45 @@ object Test { , xml ) + // Scala 3 syntax + val auxiliary0 = if true then { + + } else
empty
+ + val auxiliary1 = if true then + + else
empty
+ + val auxiliary2 = if true then
A
else
B
+ + // Note: + // This does not pass in Scala 2.12.18 and 2.13.12 + // due to "Sequence argument type annotation `: _*` cannot be used here:" + val auxiliary3 = if(true)
A
else
B
+ + // Note: This passes in Scala 2.12.18 and 2.13.12 too. + val auxiliary4 = if(true)
A
else
B
+ + // Pattern match without guard. + // Note: This passes in Scala 2.12.18 and 2.13.12 too. + val auxiliary5 = for (case _ @
empty
<- Seq(xml)) yield () + val auxiliary6 = for (case _ @
empty
<- Seq(xml)) yield () + val auxiliary7 = for (case _ @
empty
<-Seq(xml)) yield () + // Pattern match with if guard. + // Note: This passes in Scala 2.12.18 and 2.13.12 too. + val auxiliary8 = for (case _ @ FooBar <- Seq(xml) if true) + val auxiliary9 = for (case _ @ FooBar<- Seq(xml) if true) + val auxiliary10 = for (case _ @ FooBar<-Seq(xml) if true) + yield () + } + } package scala.xml { @@ -46,10 +78,7 @@ package scala.xml { def child: Seq[Node] override def toString = label + child.mkString } - class Comment(commentText: String) extends Node{ - def label = commentText - def child = Nil - } + class Elem(prefix: String, val label: String, attributes1: MetaData, scope: NamespaceBinding, minimizeEmpty: Boolean, val child: Node*) extends Node object Elem { def unapply(e:Elem):Option[(String,String,Any,Text,Any)] = Some(("dummy","dummy",null,null,null))