Unhelpful Swift 2.0 error "Type of expression is ambiguous without more context"
| Originator: | info | ||
| Number: | rdar://22677649 | Date Originated: | 13-Sep-2015 02:33 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 7.0 GM |
| Classification: | Enhancement | Reproducible: | Always |
Summary:
I ran into this error while working on ReactiveCocoa, specifically on this extension:
extension SignalProducer where T: SignalProducerType, E == T.E {
@warn_unused_result(message="Did you forget to call `start` on the producer?")
public func flatten(strategy: FlattenStrategy) -> SignalProducer<T.T, E> {
return lift { (signal: Signal<T.T, E>) -> Signal<T.T, E> in
return signal.flatten(strategy)
}
}
}
“Type of expression is ambiguous without more context” was, well, ambiguous.
Steps to Reproduce:
- Open attached project (ReactiveCocoa.xcworkspace)
- Compile ReactiveCocoa iOS framework
Expected Results:
Compilation fails in SignalProducer.swift:1100 with a more useful error, explaining which method it’s trying to find for what values of T and E, and ideally showing that it found a similar, compatible method.
Actual Results:
Compilation fails with error “Type of expression is ambiguous without more context”, but no more information.
Notes:
- The fix was to change the input signal of the closure to Signal<T, E> (instead of T.T).
- Note that this is in some intermediate state while I was working on a feature, so tests (and possibly other things) are currently broken.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!