[ConstraintSystem] Introduce a fix for assignment type mismatch

Introduce a fix/diagnostic when there is a contextual mismatch
between source and destination types of the assignment e.g.:

```swift
var x: Int = 0
x = 4.0 // destination expects an `Int`, but source is a `Double`
```
This commit is contained in:
Pavel Yaskevich
2019-09-19 22:02:33 -07:00
parent 81c7be86db
commit 8eaeb51fe5
6 changed files with 79 additions and 14 deletions

View File

@@ -17,14 +17,14 @@ struct YourFoo: Foo {}
func someTypeIsTheSame() {
var a = foo(0)
a = foo(0)
a = foo("") // expected-error{{cannot convert value of type 'String' to expected argument type 'Int'}}
a = foo("") // expected-error{{cannot assign value of type 'some Foo' (result of 'foo') to type 'some Foo' (result of 'foo')}}
var b = foo("")
b = foo(0) // expected-error{{cannot convert value of type 'Int' to expected argument type 'String'}}
b = foo(0) // expected-error{{cannot assign value of type 'some Foo' (result of 'foo') to type 'some Foo' (result of 'foo')}}
b = foo("")
var c = foo(MyFoo())
c = foo(0) // expected-error{{cannot convert value of type 'Int' to expected argument type 'MyFoo'}}
c = foo(0) // expected-error{{cannot assign value of type 'some Foo' (result of 'foo') to type 'some Foo' (result of 'foo')}}
c = foo(MyFoo())
c = foo(YourFoo()) // expected-error{{cannot convert value of type 'YourFoo' to expected argument type 'MyFoo'}}