File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1647,9 +1647,10 @@ bool AssignmentFailure::diagnoseAsError() {
1647
1647
});
1648
1648
1649
1649
if (foundProperty != results.end ()) {
1650
- emitDiagnostic (Loc, diag::masked_instance_variable,
1650
+ auto startLoc = immutableExpr->getStartLoc ();
1651
+ emitDiagnostic (startLoc, diag::masked_instance_variable,
1651
1652
typeContext->getSelfTypeInContext ())
1652
- .fixItInsert (Loc , " self." );
1653
+ .fixItInsert (startLoc , " self." );
1653
1654
}
1654
1655
}
1655
1656
Original file line number Diff line number Diff line change @@ -712,4 +712,17 @@ struct S {
712
712
x += 1 // expected-error {{left side of mutating operator isn't mutable: 'x' is a 'let' constant}}
713
713
}
714
714
}
715
+
716
+ func bar( ) {
717
+ // SR-11787: Make sure we insert "self." in the right location.
718
+ let x = 0 // expected-note 3{{change 'let' to 'var' to make it mutable}}
719
+ x += 1 // expected-error {{left side of mutating operator isn't mutable: 'x' is a 'let' constant}}
720
+ // expected-note@-1 {{add explicit 'self.' to refer to mutable property of 'S'}} {{5-5=self.}}
721
+
722
+ ( try x) += 1 // expected-error {{left side of mutating operator isn't mutable: 'x' is a 'let' constant}}
723
+ // expected-note@-1 {{add explicit 'self.' to refer to mutable property of 'S'}} {{10-10=self.}}
724
+
725
+ x = 1 // expected-error {{cannot assign to value: 'x' is a 'let' constant}}
726
+ // expected-note@-1 {{add explicit 'self.' to refer to mutable property of 'S'}} {{5-5=self.}}
727
+ }
715
728
}
You can’t perform that action at this time.
0 commit comments