From 51be8863fc1a5b1396b14e2e1d59ff3ab43263da Mon Sep 17 00:00:00 2001 From: EnzeXing Date: Fri, 3 Nov 2023 11:53:15 -0400 Subject: [PATCH 1/2] Fix i18629 --- compiler/src/dotty/tools/dotc/transform/init/Objects.scala | 5 +++-- tests/init-global/pos/i18629.scala | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tests/init-global/pos/i18629.scala diff --git a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala index 8556ced63008..53c210a0f0e4 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala @@ -1418,7 +1418,7 @@ object Objects: val applyDenot = getMemberMethod(scrutineeType, nme.apply, applyType(elemType)) val applyRes = call(scrutinee, applyDenot.symbol, TraceValue(Bottom, summon[Trace]) :: Nil, scrutineeType, superType = NoType, needResolve = true) - if isWildcardStarArg(pats.last) then + if isWildcardStarArgList(pats) then if pats.size == 1 then // call .toSeq val toSeqDenot = scrutineeType.member(nme.toSeq).suchThat(_.info.isParameterless) @@ -1433,7 +1433,8 @@ object Objects: end if else // no patterns like `xs*` - for pat <- pats do evalPattern(applyRes, pat) + for pat <- pats do evalPattern(applyRes, pat) + end if end evalSeqPatterns diff --git a/tests/init-global/pos/i18629.scala b/tests/init-global/pos/i18629.scala new file mode 100644 index 000000000000..029319a5785b --- /dev/null +++ b/tests/init-global/pos/i18629.scala @@ -0,0 +1,5 @@ +object Foo { + val bar = List() match { + case List() => ??? + } +} From 321d7e0bb2cd7323d8713e28fa65a46c9068278a Mon Sep 17 00:00:00 2001 From: EnzeXing Date: Sat, 4 Nov 2023 09:42:23 -0400 Subject: [PATCH 2/2] Modify test --- tests/init-global/pos/i18629.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/init-global/pos/i18629.scala b/tests/init-global/pos/i18629.scala index 029319a5785b..f97c21ee918d 100644 --- a/tests/init-global/pos/i18629.scala +++ b/tests/init-global/pos/i18629.scala @@ -1,5 +1,6 @@ object Foo { val bar = List() match { case List() => ??? + case _ => ??? } }