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-9278] Unable to constrain a nested type which introduces no new generics #51750

Closed
djehrlich opened this issue Nov 16, 2018 · 6 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself

Comments

@djehrlich
Copy link

Previous ID SR-9278
Radar None
Original Reporter @djehrlich
Type Bug
Status Closed
Resolution Done
Environment

Xcode 10.1

Apple Swift version 4.2.1 (swiftlang-100.11.42 clang-1000.11.45.1)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @AnthonyLatsis
Priority Medium

md5: 7b4c5a4e94c7c3bf6e58535d54334a90

Issue Description:

class Outer<Channel> {
    class Generic<T> where Channel == Int {}
    class Nongeneric where Channel == Int {}
}

Should the “Nongeneric” inner class compile?

The “Generic” inner class compiles, but the “Nongeneric” inner class fails to compile with the error:

‘where’ clause cannot be attached to a non-generic declaration

@belkadan
Copy link
Contributor

I'm not sure either of them should compile. @slavapestov, @DougGregor?

@slavapestov
Copy link
Contributor

I agree we should revisit this. I'm in favor of allowing both to compile, but in the meantime, you can define Nongeneric inside a constrained extension of Outer instead.

@DougGregor
Copy link
Member

I agree that it should be consistent either way, and I'd be fine with pursuing an extension to allow both to compile.

@slavapestov
Copy link
Contributor

This is going through swift evolution now: https://forums.swift.org/t/where-clauses-on-contextually-generic-declarations/22449

@AnthonyLatsis
Copy link
Collaborator

#23489

@AnthonyLatsis
Copy link
Collaborator

Implemented (Swift 5.3)

@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 itself
Projects
None yet
Development

No branches or pull requests

5 participants