I am using Xcode 9.2.
I am receiving the error:
Cannot convert value of type '(ValueType2) -> Void' to expected argument type '(_) -> Void'
I have the following code:
import UIKit
enum Value<ValueType> {
case hasValue(ValueType)
}
class BaseClass<ValueType> {
var value: Value<ValueType>?
func f1<ValueType2>(closure: @escaping (ValueType, @escaping (ValueType2) -> Void) -> Void ){
let s1 = SubClass<ValueType2>()
// The point of the generic type conversion issue
// Cannot convert value of type '(ValueType2) -> Void' to expected argument type '(_) -> Void'
closure(value!, s1.f2)
}
}
class SubClass<ValueType>: BaseClass<ValueType> {
func f2(value: ValueType) -> Void { /* DO SOMETHING */ }
}
I am unsure whether this is related to the Swift bug being fixed in Swift 4.1:
Swift Generics: Cannot convert value of type to expected argument type
As autocomplete knows the class's correct generic type parameter & function's parameter - ValueType2
- in both cases.
Any ideas on how to overcome this error?
Thanks