Skip to content

Commit 6b8b260

Browse files
Merge pull request #4877 from dotty-staging/fix-tasty-reflect-literal-seq-unapply
Fix Tasty reflect with varargs in unapply
2 parents 02ee000 + 457b554 commit 6b8b260

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
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 {
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
# scala.MatchError: SeqLiteral in pattern
2-
i3248.scala
3-
t6541.scala
4-
51
# Stackoverflow
62
t10594.scala
7-
8-
i4557.scala
9-
i4557a.scala

0 commit comments

Comments
 (0)