-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesfeatureA feature request or implementationA feature request or implementationimprovementswift evolution implementedFlag → feature: A feature that was approved through the Swift evolution process and implementedFlag → feature: A feature that was approved through the Swift evolution process and implementedtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistypesFeature: typesFeature: types
Description
Previous ID | SR-4758 |
Radar | rdar://problem/58438127 |
Original Reporter | @nsalmoria |
Type | Improvement |
Environment
Swift Development Snapshot 2017-04-24 (a)
Xcode 8.3.2
macOS Sierra 10.12.4
Additional Detail from JIRA
Votes | 3 |
Component/s | Compiler |
Labels | Improvement |
Assignee | @slavapestov |
Priority | Medium |
md5: 992bea1bd30120d41ee308b8b85d8e1e
is duplicated by:
- [SR-7336] Protocol with same-type constraint on associated type "can only be used as generic constraint" #49884
- [SR-9260] Allow protocol types with fully specified associated types in all type positions (function arguments etc.) #51737
- [SR-9501] Subclass existential with predefined associated type witness should be supported as existential #51955
relates to:
Issue Description:
With the implementation of SE-0142, it is now possible to force the associated types of a derived protocol to be of a specific type.
Arguably, when all the associated types are restricted, it should be possible to use the derived protocol as the type of a variable. However, the compiler still rejects the code.
Example:
protocol A {
associatedtype B
}
protocol C: A where B == Int {
}
struct D {
var c: C // error: Protocol 'C' can only be used as a generic constraint because it has Self or associated type requirements
}
In the example above, protocol C has no degrees of freedom so it shouldn't need to be restricted to generic code.
Metadata
Metadata
Assignees
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesfeatureA feature request or implementationA feature request or implementationimprovementswift evolution implementedFlag → feature: A feature that was approved through the Swift evolution process and implementedFlag → feature: A feature that was approved through the Swift evolution process and implementedtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistypesFeature: typesFeature: types