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-2843] P1 & P2.Type should be warned #45437

Closed
rintaro mannequin opened this issue Oct 4, 2016 · 3 comments
Closed

[SR-2843] P1 & P2.Type should be warned #45437

rintaro mannequin opened this issue Oct 4, 2016 · 3 comments
Assignees
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation improvement parser Area → compiler: The legacy C++ parser

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Oct 4, 2016

Previous ID SR-2843
Radar None
Original Reporter @rintaro
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI, Parser
Assignee @rintaro
Priority Medium

md5: fbd582e6c946f2b68fd9f11d57aa8e9b

Issue Description:

These constructs are very confusing for me:

typealias A = P1 & P2? // protocol<P1, P2>?
typealias B = P1 & P2.Type // protocol<P1, P2>.Type
typealias C = P1 & P2.Protocol // protocol<P1, P2>.Protocol

We should warn with fix-it to enclose protocol composition with parens. (e.g. (P1 & P2).Type)
Or reject them with error message such as:

error: non-protocol type 'P2?' cannot form a protocol composition
typealias D = P1 & P2? & P3
                   ^~~
@belkadan
Copy link
Contributor

belkadan commented Oct 4, 2016

Warning in Swift 3, error in Swift 4, perhaps?

@rintaro
Copy link
Mannequin Author

rintaro mannequin commented Oct 14, 2016

PR: #5290

@rintaro
Copy link
Mannequin Author

rintaro mannequin commented Oct 19, 2016

Merged

@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
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation improvement parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

1 participant