mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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'}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user