[ConstraintSystem] Detect and fix extraneous use of &

Diagnose extraneous use of address of (`&`) which could only be
associated with arguments to `inout` parameters e.g.

```swift
struct S {}

var a: S = ...
var b: S = ...

a = &b
```
This commit is contained in:
Pavel Yaskevich
2019-05-06 11:18:47 -07:00
parent 43526d031c
commit 3af163a94c
5 changed files with 61 additions and 1 deletions

View File

@@ -2674,3 +2674,9 @@ bool InvalidMethodRefInKeyPath::diagnoseAsError() {
getName(), isForKeyPathDynamicMemberLookup());
return true;
}
bool InvalidUseOfAddressOf::diagnoseAsError() {
auto *anchor = cast<AssignExpr>(getAnchor());
emitDiagnostic(anchor->getSrc()->getLoc(), diag::extraneous_address_of);
return true;
}