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-8247] Associated type inheriting from generic class with Self as a parameter prints canonical type in errors #50779

Closed
huonw mannequin opened this issue Jul 13, 2018 · 4 comments · Fixed by #71354
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances diagnostics QoI Bug: Diagnostics Quality of Implementation protocol Feature → type declarations: Protocol declarations Self in protocol Feature → types: The 'Self' type in protocols swift 5.10 type checker Area → compiler: Semantic analysis

Comments

@huonw
Copy link
Mannequin

huonw mannequin commented Jul 13, 2018

Previous ID SR-8247
Radar None
Original Reporter @huonw
Type Bug
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, DiagnosticsQoI
Assignee @slavapestov
Priority Medium

md5: a7f630ed225df1f60e8817ca991f4aa5

cloned from:

  • SR-8028 Protocol with where class constraint fails to compile, but same extension succeeds

relates to:

  • SR-10612 Illegal Instruction: 4 when compiling with Xcode 10.2.1
  • SR-10712 Cannot conform to protocol with associated type constrained to generic class specialised by associated type

Issue Description:

Apologies if the sample a little noisy, tried cleaning it up as much as could in available time. The following fails to build, but replaced with commented lines does compile. Intentional? Why?

@huonw
Copy link
Mannequin Author

huonw mannequin commented Jul 13, 2018

The following is a correctly not-accepted version of the reduction of #50561:

protocol SecureCodingProvider {
    associatedtype T : Generic<Self>
}

class Generic<Value> {}

internal struct Foo {}

extension Foo: SecureCodingProvider {
    class T {}
}

The error message is:

sr8028.swift:9:1: error: type 'Foo' does not conform to protocol 'SecureCodingProvider'
extension Foo: SecureCodingProvider {
^
sr8028.swift:10:11: note: possibly intended match 'Foo.T' does not inherit from 'Generic<τ_0_0>'
    class T {}
          ^
sr8028.swift:2:20: note: protocol requires nested type 'T'; do you want to add it?
    associatedtype T : Generic<Self>
                   ^

The Generic<τ_0_0> should be either Generic<Self> to at least match the protocol, or, better, Generic<Foo>.

@belkadan
Copy link
Contributor

Looks like we made it to Generic<Self> in Swift 5, at least.

@slavapestov
Copy link
Member

I looked at this recently and IIRC its still failing to apply the right substitutions somewhere.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@slavapestov
Copy link
Member

Generic superclass requirements in protocols were fixed by #71354.

@AnthonyLatsis AnthonyLatsis added type checker Area → compiler: Semantic analysis conformances Feature → protocol: protocol conformances swift 5.10 protocol Feature → type declarations: Protocol declarations Self in protocol Feature → types: The 'Self' type in protocols labels Feb 7, 2024
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 conformances Feature → protocol: protocol conformances diagnostics QoI Bug: Diagnostics Quality of Implementation protocol Feature → type declarations: Protocol declarations Self in protocol Feature → types: The 'Self' type in protocols swift 5.10 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants