mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
15 lines
247 B
Swift
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 }
|
|
}
|
|
}
|