Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Sema/MiscDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
DC = DC->getParent();
}
}

const_cast<Expr *>(E)->walk(DiagnoseWalker(ctx, ACE));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void typeCheckASTNode(ASTNode &node, DeclContext *DC,
/// value if an error occurred while type checking the transformed body.
Optional<BraceStmt *> applyResultBuilderBodyTransform(
FuncDecl *func, Type builderType,
bool ClosuresInResultBuilderDontParticipateInInference = true);
bool ClosuresInResultBuilderDontParticipateInInference = false);

/// Find the return statements within the body of the given function.
std::vector<ReturnStmt *> findReturnStatements(AnyFunctionRef fn);
Expand Down
31 changes: 31 additions & 0 deletions test/expr/closure/closures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(first: T) -> Void { }
static func buildPartialBlock<T>(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)
}
}
}