Skip to content

Commit

Permalink
Fix i18629 (#18839)
Browse files Browse the repository at this point in the history
This PR fixes the minimized test of #18629 that could previously crash
the global initialization checker because of empty patterns when
matching against `List()`.
  • Loading branch information
olhotak authored Nov 4, 2023
2 parents 6f9c933 + 321d7e0 commit 5454110
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/init/Objects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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


Expand Down
6 changes: 6 additions & 0 deletions tests/init-global/pos/i18629.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Foo {
val bar = List() match {
case List() => ???
case _ => ???
}
}

0 comments on commit 5454110

Please sign in to comment.