From 64bc1eb2ae9e9882c10247ffff3b834282e5221b Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 31 Jul 2018 11:43:40 +0200 Subject: [PATCH 1/2] Fix Tasty reflect with varargs in unapply --- .../src/dotty/tools/dotc/tastyreflect/TastyImpl.scala | 8 ++++++-- compiler/test/dotc/run-decompilation.blacklist | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala index 27e1e849b9d4..048198359ae2 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala @@ -587,10 +587,14 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s object Unapply extends UnapplyExtractor { def unapply(x: Pattern)(implicit ctx: Context): Option[(Term, List[Term], List[Pattern])] = x match { - case Trees.UnApply(fun, implicits, patterns) => Some((fun, implicits, patterns)) - case Trees.Typed(Trees.UnApply(fun, implicits, patterns), _) => Some((fun, implicits, patterns)) + case Trees.UnApply(fun, implicits, patterns) => Some((fun, implicits, effectivePatterns(patterns))) + case Trees.Typed(Trees.UnApply(fun, implicits, patterns), _) => Some((fun, implicits, effectivePatterns(patterns))) case _ => None } + private def effectivePatterns(patterns: List[Pattern]): List[Pattern] = patterns match { + case patterns0 :+ Trees.SeqLiteral(elems, _) => patterns0 ::: elems + case _ => patterns + } } object Alternative extends AlternativeExtractor { diff --git a/compiler/test/dotc/run-decompilation.blacklist b/compiler/test/dotc/run-decompilation.blacklist index 053324373841..9e190f059708 100644 --- a/compiler/test/dotc/run-decompilation.blacklist +++ b/compiler/test/dotc/run-decompilation.blacklist @@ -1,7 +1,3 @@ -# scala.MatchError: SeqLiteral in pattern -i3248.scala -t6541.scala - # Stackoverflow t10594.scala From 457b5542ea708cd5c400a6f4919b357bcac86ea5 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 31 Jul 2018 11:50:35 +0200 Subject: [PATCH 2/2] Add regression tests --- compiler/test/dotc/run-decompilation.blacklist | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/test/dotc/run-decompilation.blacklist b/compiler/test/dotc/run-decompilation.blacklist index 9e190f059708..07f14e74001f 100644 --- a/compiler/test/dotc/run-decompilation.blacklist +++ b/compiler/test/dotc/run-decompilation.blacklist @@ -1,5 +1,2 @@ # Stackoverflow t10594.scala - -i4557.scala -i4557a.scala