Skip to content

Commit 7080971

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-rebranch
2 parents 82d07ec + 5f62deb commit 7080971

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/Parse/ParseType.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,11 @@ Parser::parseTypeSimpleOrComposition(Diag<> MessageID,
841841
// Diagnose invalid `some` after an ampersand.
842842
if (Tok.is(tok::identifier) && Tok.getRawText() == "some") {
843843
auto badLoc = consumeToken();
844-
845-
// TODO: Fixit to move to beginning of composition.
846-
diagnose(badLoc, diag::opaque_mid_composition);
847-
844+
845+
diagnose(badLoc, diag::opaque_mid_composition)
846+
.fixItRemove(badLoc)
847+
.fixItInsert(FirstTypeLoc, "some ");
848+
848849
if (opaqueLoc.isInvalid())
849850
opaqueLoc = badLoc;
850851
}

test/type/opaque.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,8 @@ dynamic func foo<S>(_ s: S) -> some Proto {
475475
func foo_repl<S>(_ s: S) -> some Proto {
476476
return I()
477477
}
478+
479+
protocol SomeProtocolA {}
480+
protocol SomeProtocolB {}
481+
struct SomeStructC: SomeProtocolA, SomeProtocolB {}
482+
let someProperty: SomeProtocolA & some SomeProtocolB = SomeStructC() // expected-error {{'some' should appear at the beginning of a composition}}{{35-40=}}{{19-19=some }}

0 commit comments

Comments
 (0)