Skip to content
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

[SR-7192] Conditional conformance with array/dictionary literals #49740

Closed
swift-ci opened this issue Mar 13, 2018 · 2 comments
Closed

[SR-7192] Conditional conformance with array/dictionary literals #49740

swift-ci opened this issue Mar 13, 2018 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7192
Radar rdar://problem/38461036
Original Reporter Vermeulen (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 9.3 beta 4 and the Swift version that comes with it (also tried the March 12 Swift 4.1 snapshot, same issue).

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 327e6fe39d120d90dd29c451b1b8edda

Issue Description:

struct Foo {}
protocol Bar {}

extension Array: Bar where Element == Foo {}

let foo = Foo()
let bar: Bar = [foo]           // "Contextual type `Bar` cannot be used with array literal"

let array = [foo]
let bar2: Bar = array          // works fine

let bar3: Bar = [foo] as [Foo] // also works fine

Similar to SR-6941 but not exactly the same. Not limited to array literals, the same issue arises with dictionary literals.

@belkadan
Copy link
Contributor

The key point is that this does work with a non-conditional conformance. Thanks!

@swift-ci create

@huonw
Copy link
Mannequin

huonw mannequin commented Mar 22, 2018

Fixed in #15415 merged as 2f6ca48

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants