Files
swift-mirror/test/Constraints/implicit_last_exprs_double_cgfloat_conversion.swift
Slava Pestov c197635ad9 AST: Factor out ASTContext::get{CGFloat,Double}InitDecl() from CSApply.cpp
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.
2026-03-20 15:56:32 -04:00

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
}
}
}
}