Skip to content

Commit f8fb386

Browse files
committed
---
yaml --- r: 343485 b: refs/heads/master-rebranch c: 535364c h: refs/heads/master i: 343483: fa2bb09
1 parent f6454ef commit f8fb386

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 4c8450e3a96912142893e7d807671223b03f4d53
1458+
refs/heads/master-rebranch: 535364c0300c2323a9330a675e308f575be40ba9
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/lib/Sema/TypeCheckProtocol.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,10 +2116,11 @@ diagnoseMatch(ModuleDecl *module, NormalProtocolConformance *conformance,
21162116
auto witness = match.Witness;
21172117
auto diag =
21182118
diags.diagnose(witness, diag::protocol_witness_settable_conflict);
2119-
auto VD = cast<VarDecl>(witness);
2120-
if (VD->hasStorage()) {
2121-
auto PBD = VD->getParentPatternBinding();
2122-
diag.fixItReplace(PBD->getStartLoc(), getTokenText(tok::kw_var));
2119+
if (auto VD = dyn_cast<VarDecl>(witness)) {
2120+
if (VD->hasStorage()) {
2121+
auto PBD = VD->getParentPatternBinding();
2122+
diag.fixItReplace(PBD->getStartLoc(), getTokenText(tok::kw_var));
2123+
}
21232124
}
21242125
break;
21252126
}
@@ -2166,7 +2167,7 @@ diagnoseMatch(ModuleDecl *module, NormalProtocolConformance *conformance,
21662167
case MatchKind::RethrowsConflict: {
21672168
auto witness = match.Witness;
21682169
auto diag =
2169-
diags.diagnose(match.Witness, diag::protocol_witness_rethrows_conflict);
2170+
diags.diagnose(witness, diag::protocol_witness_rethrows_conflict);
21702171
auto FD = cast<FuncDecl>(witness);
21712172
diag.fixItReplace(FD->getThrowsLoc(), getTokenText(tok::kw_rethrows));
21722173
break;

branches/master-rebranch/test/decl/protocol/req/witness_fix_its.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,11 @@ struct ConformsToFoo: Foo { // expected-error {{type 'ConformsToFoo' does not co
2626
var bar5: Int { return 0 } // expected-note {{candidate is not settable, but protocol requires it}}{{none}}
2727
subscript(_ pos: Int) -> Int { return 0 } // expected-note {{candidate operates on an instance, not a type as required}}{{3-3=static}}
2828
}
29+
30+
protocol Foo1 {
31+
subscript(value: Bool) -> Bool { get set } // expected-note {{protocol requires subscript with type '(Bool) -> Bool'; do you want to add a stub?}}
32+
}
33+
34+
struct ConformsToFoo1: Foo1 { // expected-error {{type 'ConformsToFoo1' does not conform to protocol 'Foo1'}}
35+
subscript(value: Bool) -> Bool { return false } // expected-note {{candidate is not settable, but protocol requires it}}{{none}}
36+
}

0 commit comments

Comments
 (0)