Files
swift-mirror/test/Interpreter/switch_objc.swift
Michael Gottesman adcfda6f6d [silgenpattern] When binding values, use a ManagedValue instead of an RValue to avoid implicitly exploding tuples.
In SILGenPattern, we need to be able to unforward cleanups when we explode
tuples. Thus we can't use RValue in SILGenPattern since it may implicitly
explode tuples (which without modifying RValue itself we can not
unforward). This patch removes a specific RValue usage that we can replace with
the use of a ManagedValue instead.

rdar://49903264
2019-05-16 12:41:08 -07:00

41 lines
920 B
Swift

// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: objc_interop
import StdlibUnittest
import Foundation
var SwitchTestSuite = TestSuite("SwitchObjC")
defer { runAllTests() }
SwitchTestSuite.test("Resilient Type Tuple Initialization Construction") {
// This test make sure that this works for URL specifically. There is a
// separate artificial test case in switch_resilience that uses our own
// resilient type.
enum Enum {
case first(url: URL, void: Void)
}
func getEnum() -> Enum {
let url = URL(string: "http://foobar.com")!
return .first(url: url, void: ())
}
func getBool() -> Bool { return false }
switch getEnum() {
case let .first(x, y) where getBool():
print("first")
case .first:
print("second")
}
switch getEnum() {
case let .first(value) where getBool():
print("third")
case .first:
print("fourth")
}
print("done")
}