Skip to content

Commit 98a03ea

Browse files
committed
Fix Tasty reflect with varargs in unapply
1 parent 608caab commit 98a03ea

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,14 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s
587587

588588
object Unapply extends UnapplyExtractor {
589589
def unapply(x: Pattern)(implicit ctx: Context): Option[(Term, List[Term], List[Pattern])] = x match {
590-
case Trees.UnApply(fun, implicits, patterns) => Some((fun, implicits, patterns))
591-
case Trees.Typed(Trees.UnApply(fun, implicits, patterns), _) => Some((fun, implicits, patterns))
590+
case Trees.UnApply(fun, implicits, patterns) => Some((fun, implicits, effectivePatterns(patterns)))
591+
case Trees.Typed(Trees.UnApply(fun, implicits, patterns), _) => Some((fun, implicits, effectivePatterns(patterns)))
592592
case _ => None
593593
}
594+
private def effectivePatterns(patterns: List[Pattern]): List[Pattern] = patterns match {
595+
case patterns0 :+ Trees.SeqLiteral(elems, _) => patterns0 ::: elems
596+
case _ => patterns
597+
}
594598
}
595599

596600
object Alternative extends AlternativeExtractor {

compiler/test/dotc/run-decompilation.blacklist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ t4601.scala
4040
t6633.scala
4141
arrays.scala
4242

43-
# scala.MatchError: SeqLiteral in pattern
44-
i3248.scala
45-
t6541.scala
46-
4743
# Stackoverflow
4844
t10594.scala
4945

0 commit comments

Comments
 (0)