Skip to content

[ConstraintSystem] Detect and diagnose conversion failures related to… #24791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2019

Conversation

xedin
Copy link
Contributor

@xedin xedin commented May 15, 2019

… collection element types

Detect and diagnose a contextual mismatch between expected
collection element type and the one provided (e.g. source
of the assignment or argument to a call) e.g.:

let _: [Int] = ["hello"]

func foo(_: [Int]) {}
foo(["hello"])

Resolves: rdar://problem/33914447

@xedin
Copy link
Contributor Author

xedin commented May 15, 2019

Related to #24754

@xedin xedin requested a review from DougGregor May 15, 2019 00:22
… collection element types

Detect and diagnose a contextual mismatch between expected
collection element type and the one provided (e.g. source
of the assignment or argument to a call) e.g.:

```swift
let _: [Int] = ["hello"]

func foo(_: [Int]) {}
foo(["hello"])
```
@xedin xedin force-pushed the diag-collection-element-conversions branch from c1da131 to b9a0ca6 Compare May 15, 2019 00:35
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@@ -26,7 +26,7 @@ func arraySameType() {

let _: SameType = [works]
let _: SameType = [fails]
// expected-error@-1 {{value of type '[Fails]' does not conform to specified type 'SameType'}}
// expected-error@-1 {{cannot convert value of type 'Fails' to expected element type 'Works'}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer!

@xedin
Copy link
Contributor Author

xedin commented May 15, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c1da13188c3bf2551ce30bc3351208a7c819ba34

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c1da13188c3bf2551ce30bc3351208a7c819ba34

@xedin
Copy link
Contributor Author

xedin commented May 15, 2019

@swift-ci please test macOS platform

@xedin
Copy link
Contributor Author

xedin commented May 15, 2019

@swift-ci please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - b9a0ca6

@xedin
Copy link
Contributor Author

xedin commented May 15, 2019

@swift-ci please test macOS platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants