diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index 09a7473999eae..ebe92d363fd55 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -2015,6 +2015,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E, DC = DC->getParent(); } } + const_cast(E)->walk(DiagnoseWalker(ctx, ACE)); } diff --git a/lib/Sema/TypeChecker.h b/lib/Sema/TypeChecker.h index 91418e8f31868..36a9149ade562 100644 --- a/lib/Sema/TypeChecker.h +++ b/lib/Sema/TypeChecker.h @@ -459,7 +459,7 @@ void typeCheckASTNode(ASTNode &node, DeclContext *DC, /// value if an error occurred while type checking the transformed body. Optional applyResultBuilderBodyTransform( FuncDecl *func, Type builderType, - bool ClosuresInResultBuilderDontParticipateInInference = true); + bool ClosuresInResultBuilderDontParticipateInInference = false); /// Find the return statements within the body of the given function. std::vector findReturnStatements(AnyFunctionRef fn); diff --git a/test/expr/closure/closures.swift b/test/expr/closure/closures.swift index 9a3c8b11ccfc3..521e351d1283e 100644 --- a/test/expr/closure/closures.swift +++ b/test/expr/closure/closures.swift @@ -891,3 +891,34 @@ func test60781() -> Int { func test60781_MultiArg() -> Int { f60781({ 1 }, { 1 }) // expected-error{{conflicting arguments to generic parameter 'T' ('Int' vs. '() -> Int')}} } + +@resultBuilder +struct VoidBuilder { + static func buildBlock() -> Void { } + static func buildPartialBlock(first: T) -> Void { } + static func buildPartialBlock(accumulated: Void, next: T) -> Void { } +} + +final class EscapingWrapper { + static func wrapper(_ closure: @escaping () -> Void) { + closure() + } +} + +final class TestGithubIssue64757 { + var instanceProperty: String = "instance property" + + @VoidBuilder + var void: Void { + EscapingWrapper.wrapper { [weak self] in + print(instanceProperty) // expected-error {{reference to property 'instanceProperty' in closure requires explicit use of 'self' to make capture semantics explicit}} + + if let self { + print(instanceProperty) + } + + guard let self else { return } + print(instanceProperty) + } + } +}