Skip to content

Commit 8a6d056

Browse files
committed
Another test case for multipayload enums with different payload types
This test case would also crash before my recent IRGen multipayload enum fix.
1 parent 6fc63bc commit 8a6d056

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/Interpreter/enum_bridged.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %s -o %t/a.out
3+
// RUN: %target-run %t/a.out | %FileCheck %s
4+
// REQUIRES: executable_test
5+
6+
// REQUIRES: objc_interop
7+
import Foundation
8+
class K {}
9+
enum MixedBridged {
10+
case Native(K)
11+
case Bridged([K])
12+
case Empty
13+
}
14+
15+
struct Container {
16+
var storage : MixedBridged = .Empty
17+
18+
mutating func adoptStyle(_ s: [K]) {
19+
storage = .Bridged(s)
20+
}
21+
}
22+
23+
func copyStorage(_ s: [K], _ x : Container) -> Container {
24+
var c = x
25+
c.adoptStyle(s)
26+
return c
27+
}
28+
29+
func testCase() {
30+
let nsArray = NSArray(objects:K(), K()) as! [K]
31+
let l = Container()
32+
let c = copyStorage(nsArray, l)
33+
print(c)
34+
}
35+
36+
// CHECK: Container(storage: a.MixedBridged.Bridged([a.K, a.K]))
37+
testCase()

0 commit comments

Comments
 (0)