-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconformancesFeature → protocol: protocol conformancesFeature → protocol: protocol conformancesgeneric constraintsFeature → generics: generic constraintsFeature → generics: generic constraintsgenericsFeature: generic declarations and typesFeature: generic declarations and typesswift 5.10type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error
Description
| Previous ID | SR-8719 |
| Radar | None |
| Original Reporter | Nasamura (JIRA User) |
| Type | New Feature |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | New Feature, AssociatedTypeInference |
| Assignee | @DougGregor |
| Priority | Medium |
md5: 583798a6a88eb7fa7fc4d602ce5716b8
relates to:
Issue Description:
Xcode: Version 10.0 beta 6 (10L232m)
public protocol Prot1 {
associatedtype AType: StringProtocol
}
public protocol Prot2 {
associatedtype BType: StringProtocol
}
public protocol Prot3: Prot1, Prot2 where AType == BType {
}
struct Struct1: Prot3 {
typealias AType = String
}
// Type 'Struct1' does not conform to protocol 'Prot2'This is a simplified example of where I'm combining two protocols and AType will always equal BType but the compiler is not able to infer one type from the other and has to be explicitly stated. This leads to unnecessary code duplication.
Metadata
Metadata
Assignees
Labels
associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconformancesFeature → protocol: protocol conformancesFeature → protocol: protocol conformancesgeneric constraintsFeature → generics: generic constraintsFeature → generics: generic constraintsgenericsFeature: generic declarations and typesFeature: generic declarations and typesswift 5.10type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error