Skip to content

Commit 14632b7

Browse files
committed
Update tests after pulling fix from master
1 parent 64fc43e commit 14632b7

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Diff for: lib/Sema/MiscDiagnostics.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,9 @@ class ImplicitSelfUsageChecker : public BaseDiagnosticWalker {
18821882
}
18831883

18841884
// If the self decl refers to a weak capture, then implicit self is not
1885-
// allowed. Self must me unwrapped in a weak self closure.
1885+
// allowed. Self must be unwrapped in a `guard let self` / `if let self`
1886+
// condition first. This is usually enforced by the type checker, but
1887+
// isn't in some cases (e.g. when calling a method on `Optional<Self>`).
18861888
// - When validating implicit self usage in a nested closure, it's not
18871889
// necessary for self to be unwrapped in this parent closure. If self
18881890
// isn't unwrapped correctly in the nested closure, we would have

Diff for: test/expr/closure/closures_swift6.swift

+4-10
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,14 @@ class TestGithubIssue70089 {
501501
}
502502

503503
doVoidStuff { [weak self] in
504-
doVoidStuff { [self] in // expected-error {{value of optional type 'TestGithubIssue70089?' must be unwrapped to a value of type 'TestGithubIssue70089'}} expected-note {{coalesce using '??' to provide a default when the optional value contains 'nil'}} expected-note {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
505-
x += 1
504+
doVoidStuff { [self] in
505+
x += 1 // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note{{reference 'self?.' explicitly}}
506506
}
507507
}
508508

509509
doVoidStuff { [weak self] in
510-
doVoidStuff { [self] in // expected-error {{value of optional type 'TestGithubIssue70089?' must be unwrapped to a value of type 'TestGithubIssue70089'}} expected-note {{coalesce using '??' to provide a default when the optional value contains 'nil'}} expected-note {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
511-
self.x += 1
510+
doVoidStuff { [self] in
511+
self.x += 1 // expected-error {{value of optional type 'TestGithubIssue70089?' must be unwrapped to refer to member 'x' of wrapped base type 'TestGithubIssue70089'}} expected-note {{chain the optional using '?' to access member 'x' only for non-'nil' base values}} expected-note{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
512512
}
513513
}
514514

@@ -647,12 +647,6 @@ class TestGithubIssue69911 {
647647
}
648648
}
649649
}
650-
651-
doVoidStuff { [weak self] in
652-
doVoidStuff { [self] in // expected-error {{value of optional type 'TestGithubIssue69911?' must be unwrapped to a value of type 'TestGithubIssue69911'}} expected-note{{coalesce using '??' to provide a default when the optional value contains 'nil'}} expected-note{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
653-
x += 1
654-
}
655-
}
656650
}
657651
}
658652

0 commit comments

Comments
 (0)