sema: accept an array literal of enum case references as compile-time constant

This commit is contained in:
Xi Ge
2022-03-24 20:07:23 -07:00
parent fbbfb708ec
commit 6206d7cc9d
6 changed files with 51 additions and 23 deletions

View File

@@ -0,0 +1,20 @@
// RUN: %target-typecheck-verify-swift
enum E {
case a
case b
var z: E { .b }
}
func getAE() -> E { return .a }
func test_without_const(_ : [E]) {}
func testArr(_ : _const [E]) {}
testArr([])
testArr([.a])
testArr([.a, .b])
testArr([getAE()]) // expected-error {{expect a compile-time constant literal}}
testArr([.a, .b, .a.z]) // expected-error {{expect a compile-time constant literal}}