mirror of
https://github.com/apple/swift.git
synced 2026-10-04 11:58:22 +02:00
Also, since the mock SDK's implementation of CGFloat is wrong, update some existing tests to use the real SDK instead. This exposed a few instances where the behavior was not as intended; I added FIXME comments explaining what's going on.
63 lines
1003 B
Swift
63 lines
1003 B
Swift
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ImplicitLastExprResults
|
|
|
|
// REQUIRES: objc_interop
|
|
// REQUIRES: swift_feature_ImplicitLastExprResults
|
|
|
|
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
|
|
}
|
|
}
|
|
}
|
|
}
|