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..f97c21ee918d --- /dev/null +++ b/tests/init-global/pos/i18629.scala @@ -0,0 +1,6 @@ +object Foo { + val bar = List() match { + case List() => ??? + case _ => ??? + } +}