-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
Copy link
Labels
bugA 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 itselfregressionswift 4.0
Description
| Previous ID | SR-6554 |
| Radar | None |
| Original Reporter | trimm (JIRA User) |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Environment
Swift 4.0, Swift 4.0.1
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, 4.0Regression |
| Assignee | None |
| Priority | Medium |
md5: d5270fb56c4a13ba96b13a49017fdb53
Issue Description:
public extension Optional {
public func apply<Result>(_ transform: ((Wrapped) -> Result)?) -> Result? {
return self.flatMap { value in
transform.map { $0(value) }
}
}
public func apply<Value, Result>(_ value: Value?) -> Result?
where Wrapped == (Value) -> Result
{
return value.apply(self)
}
}Possibly related to bug: https://bugs.swift.org/browse/SR-6509
This works fine under Swift3-3.2.
Actual results:
'apply' produces 'Result?', not the expected contextual result type 'Result?'
Expected results:
The code compiles, compiler infers the type of result for type of Wrapped
Metadata
Metadata
Assignees
Labels
bugA 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 itselfregressionswift 4.0