-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed as duplicate of#44398
Labels
TypeResolverbugA 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 itselfexpressionsFeature: expressionsFeature: expressionsgenericsFeature: generic declarations and typesFeature: generic declarations and typesswift 6.0swift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposalFlag → feature: A feature that warrants a Swift evolution proposaltype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inferenceunexpected errorBug: Unexpected errorBug: Unexpected error
Description
Previous ID | SR-11472 |
Radar | None |
Original Reporter | @jeremyabannister |
Type | Bug |
Status | Resolved |
Resolution | Duplicate |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, TypeChecker |
Assignee | None |
Priority | Medium |
md5: 3094e6c47b27e8d301bf4f2a2ef9c7e9
duplicates:
Issue Description:
This code compiles with Swift 5:
struct A <X> {
let dict: [Int: X]
init (dict: [Int: X]) {
self.dict = dict
}
func map <Y> (_ transform: (X)->Y) -> A<Y> {
return A<Y>(dict: dict.mapValues { transform($0) })
}
}
but this code does not:
struct A <X> {
let dict: [Int: X]
init (dict: [Int: X]) {
self.dict = dict
}
func map <Y> (_ transform: (X)->Y) -> A<Y> {
return A(dict: dict.mapValues { transform($0) })
}
}
The only difference is that I have removed the explicit type from the construction of A
in the map
method. Of course the generic parameter is already specified in two ways, one is the return type and the other is the fact that the transform spits out values of type Y
. What's going on here?
Metadata
Metadata
Assignees
Labels
TypeResolverbugA 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 itselfexpressionsFeature: expressionsFeature: expressionsgenericsFeature: generic declarations and typesFeature: generic declarations and typesswift 6.0swift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposalFlag → feature: A feature that warrants a Swift evolution proposaltype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inferenceunexpected errorBug: Unexpected errorBug: Unexpected error