Skip to content

Commit 548456d

Browse files
committed
Add test case for #64757
1 parent 1b5dab0 commit 548456d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/expr/closure/closures.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,3 +891,34 @@ func test60781() -> Int {
891891
func test60781_MultiArg() -> Int {
892892
f60781({ 1 }, { 1 }) // expected-error{{conflicting arguments to generic parameter 'T' ('Int' vs. '() -> Int')}}
893893
}
894+
895+
@resultBuilder
896+
struct VoidBuilder {
897+
static func buildBlock() -> Void { }
898+
static func buildPartialBlock<T>(first: T) -> Void { }
899+
static func buildPartialBlock<T>(accumulated: Void, next: T) -> Void { }
900+
}
901+
902+
final class EscapingWrapper {
903+
static func wrapper(_ closure: @escaping () -> Void) {
904+
closure()
905+
}
906+
}
907+
908+
final class TestGithubIssue64757 {
909+
var instanceProperty: String = "instance property"
910+
911+
@VoidBuilder
912+
var void: Void {
913+
EscapingWrapper.wrapper { [weak self] in
914+
print(instanceProperty) // expected-error {{reference to property 'instanceProperty' in closure requires explicit use of 'self' to make capture semantics explicit}}
915+
916+
if let self {
917+
print(instanceProperty)
918+
}
919+
920+
guard let self else { return }
921+
print(instanceProperty)
922+
}
923+
}
924+
}

0 commit comments

Comments
 (0)