mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Infer the return type of a closure to be () if it contains no
return statements, or a return statement with no operand. Also, fix a special-case diagnostic about converting a return expression to (1) only apply to converting the actual return expression, not an arbitrary sub-expression, and (2) use the actual operand and return types, not the drilled-down types that caused the failure. Swift SVN r30420
This commit is contained in:
@@ -41,6 +41,16 @@ public:
|
||||
assert(ACE && "should have a closure");
|
||||
}
|
||||
|
||||
/// Construct an AnyFunctionRef from a decl context that's known to
|
||||
/// be some sort of function.
|
||||
static AnyFunctionRef fromFunctionDeclContext(DeclContext *dc) {
|
||||
if (auto fn = dyn_cast<AbstractFunctionDecl>(dc)) {
|
||||
return fn;
|
||||
} else {
|
||||
return cast<AbstractClosureExpr>(dc);
|
||||
}
|
||||
}
|
||||
|
||||
CaptureInfo &getCaptureInfo() const {
|
||||
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>())
|
||||
return AFD->getCaptureInfo();
|
||||
|
||||
Reference in New Issue
Block a user