Files
swift-mirror/test/Constraints/closure_optional_chain.swift
Hamish Knight 9b64990d24 [AST] Remove the "single expression body" bit
Remove this bit from function decls and closures.
Instead, for closures, infer it from the presence
of a single return or single expression AST node
in the body, which ought to be equivalent, and
automatically takes result builders into
consideration. We can also completely drop this
query from AbstractFunctionDecl, replacing it
instead with a bit on ReturnStmt.
2024-01-30 14:08:54 +00:00

15 lines
247 B
Swift

// RUN: %target-swift-frontend -emit-sil %s
struct S {
func foo<R>(_ body: () -> R) -> R {
fatalError()
}
}
// Make sure we insert an implicit return at the end of the body.
func bar(x: S?) {
x?.foo {
if .random() { return }
}
}