File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -5157,6 +5157,14 @@ bool ConstraintSystem::repairFailures(
5157
5157
if (auto *inoutExpr = dyn_cast<InOutExpr>(AE->getSrc())) {
5158
5158
auto *loc = getConstraintLocator(inoutExpr);
5159
5159
5160
+ // Remove all of the restrictions because none of them
5161
+ // are going to succeed.
5162
+ conversionsOrFixes.erase(
5163
+ llvm::remove_if(
5164
+ conversionsOrFixes,
5165
+ [](const auto &entry) { return bool(entry.getRestriction()); }),
5166
+ conversionsOrFixes.end());
5167
+
5160
5168
if (hasFixFor(loc, FixKind::RemoveAddressOf))
5161
5169
return true;
5162
5170
Original file line number Diff line number Diff line change @@ -302,3 +302,11 @@ func test_incorrect_inout_at_assignment_source() {
302
302
s. prop = & val // expected-error {{'&' may only be used to pass an argument to inout parameter}}
303
303
}
304
304
}
305
+
306
+ // rdar://100369066 - type of expression is ambiguous when `&` is used incorrectly
307
+ func test_invalid_inout_with_restrictions( lhs: inout any BinaryInteger , rhs: any BinaryInteger ) {
308
+ lhs = & rhs // expected-error {{'&' may only be used to pass an argument to inout parameter}}
309
+
310
+ var other : ( any BinaryInteger ) ? = nil
311
+ other = & rhs // expected-error {{'&' may only be used to pass an argument to inout parameter}}
312
+ }
You can’t perform that action at this time.
0 commit comments