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-9691] Error attempting to use initializer declared in protocol despite constraint #52132

Closed
swift-ci opened this issue Jan 17, 2019 · 4 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-9691
Radar None
Original Reporter Anandabits (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 8cba6813440b087c6d956601c469e0e1

Issue Description:

struct S: RP {
    typealias R = S
}
protocol KP {
    associatedtype R: RP
}
protocol RP: KP where R == Self {
    associatedtype R = Self
}
protocol HK {
    associatedtype K: KP
}
protocol HK2: HK {}

protocol OP {
    associatedtype V: HK2 where V.K.R == S
    associatedtype C
    init(_ v: V, c: C)
}
func test<O: OP>(_ v: O.V, o: O.Type, c: O.C) {
    // Non-nominal type 'O' does not support explicit initialization
    O(v: v, c: c)
}
@belkadan
Copy link
Contributor

cc @xedin

@xedin
Copy link
Member

xedin commented Jan 31, 2019

Looks like diagnostic for this problem has been improved in 5.0:

error: extraneous argument label 'v:' in call
    O(v: v, c: c)
     ^~~~

WDYT, Anandabits (JIRA User)?

@swift-ci
Copy link
Collaborator Author

Comment by Matthew Johnson (JIRA)

Yeah, that diagnostic looks much more helpful. I'm not sure an argument label was actually the issue I was having in the code this example was extracted from, but unfortunately I worked around the issue in a different way and didn't keep the original code so I'm not able to verify. I think it's fine to close this ticket. I'll re-open a new one if necessary.

@xedin
Copy link
Member

xedin commented Jan 31, 2019

Sounds good, thank you!

@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

3 participants