mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
65 lines
1.0 KiB
Swift
65 lines
1.0 KiB
Swift
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ImplicitLastExprResults %clang-importer-sdk
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
// Experimental feature requires asserts
|
|
// REQUIRES: asserts
|
|
|
|
import Foundation
|
|
|
|
func testReturn1(_ d: Double) -> CGFloat {
|
|
print("hello")
|
|
d
|
|
}
|
|
|
|
func testReturn2(_ d: Double) -> CGFloat {
|
|
()
|
|
if .random() { d } else { 0 }
|
|
}
|
|
|
|
func testReturn3(_ d: CGFloat) -> Double {
|
|
print("hello")
|
|
switch Bool.random() { case true: d case false: 0 }
|
|
}
|
|
|
|
func testReturn4(_ d: Double) -> CGFloat {
|
|
print("hello")
|
|
if .random() {
|
|
print("hello")
|
|
d
|
|
} else {
|
|
if .random() {
|
|
print("hello")
|
|
d
|
|
} else {
|
|
0
|
|
}
|
|
}
|
|
}
|
|
|
|
func testClosure(_ d: CGFloat) {
|
|
func fn(_: () -> Double) {}
|
|
fn {
|
|
print("hello")
|
|
d
|
|
}
|
|
fn {
|
|
print("hello")
|
|
if .random() { 0.0 } else { d }
|
|
}
|
|
fn {
|
|
print("hello")
|
|
if .random() {
|
|
print("hello")
|
|
d
|
|
} else {
|
|
if .random() {
|
|
print("hello")
|
|
d
|
|
} else {
|
|
0
|
|
}
|
|
}
|
|
}
|
|
}
|