Skip to content

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

@rintaro

Description

@rintaro
mannequin
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
                   ^~~

Metadata

Metadata

Assignees

Labels

compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationimprovementparserArea → compiler: The legacy C++ parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions