Skip to content

Another test case for multipayload enums with different payload types #16948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions test/Interpreter/enum_bridged.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: executable_test

// REQUIRES: objc_interop
import Foundation
class K {}
enum MixedBridged {
case Native(K)
case Bridged([K])
case Empty
}

struct Container {
var storage : MixedBridged = .Empty

mutating func adoptStyle(_ s: [K]) {
storage = .Bridged(s)
}
}

func copyStorage(_ s: [K], _ x : Container) -> Container {
var c = x
c.adoptStyle(s)
return c
}

func testCase() {
let nsArray = NSArray(objects:K(), K()) as! [K]
let l = Container()
let c = copyStorage(nsArray, l)
print(c)
}

// CHECK: Container(storage: a.MixedBridged.Bridged([a.K, a.K]))
testCase()