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-5588] Anti-Conformance for Generic Parameters #48160

Closed
swift-ci opened this issue Jul 30, 2017 · 3 comments
Closed

[SR-5588] Anti-Conformance for Generic Parameters #48160

swift-ci opened this issue Jul 30, 2017 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5588
Radar None
Original Reporter CTMacUser (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 509a2a516b408ad50532ccf1b6d45295

Issue Description:

Generic Parameters can be specified to match conformance to a type (i.e. protocol) or protocol composition, or to exactly match another type. But there are no tests for anti-matching. For the equivalent C++ feature, an anti-match can be formed by putting the desired members in the generalization and leaving the specialization empty. But Swift, AFAIK, doesn't have this specialization model, so we're stuck.

My first guess to write these anti-matches is just sticking "!" in places:

generic-parameter-clause< generic-parameter-list >
generic-parameter-listgeneric-parameter | generic-parameter , generic-parameter-list
generic-parametertype-name
generic-parametertype-name : !opt type-identifier
‌generic-parametertype-name : !opt protocol-composition-type
generic-where-clausewhere requirement-list
‌requirement-listrequirement | requirement , requirement-list
requirementconformance-requirement | same-type-requirement
‌conformance-requirementtype-identifier : !opt type-identifier
‌conformance-requirementtype-identifier : !opt protocol-composition-type
‌same-type-requirementtype-identifier == type
‌same-type-requirementtype-identifier != type

@swift-ci
Copy link
Collaborator Author

Comment by Daryle Walker (JIRA)

This request may not be workable, but I posted another one that is closer to what may be needed. It's [SR-5589].

@swift-ci
Copy link
Collaborator Author

Comment by Daryle Walker (JIRA)

Actually, it more that the anti-conformance requirement may not be workable. The anti-same-type requirement could still be useful, because that check can't be retroactively changed (AFAIK).

@belkadan
Copy link
Contributor

This should stay on swift-evolution and go through the Swift Evolution Process; we don't gain anything by making it a bug.

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

No branches or pull requests

2 participants