internal protocol Reducer {
associatedtype S : BaseState
associatedtype A : BaseAction
func reduce(state: S, action: A) -> S
}
internal class ReducerImpl : Reducer {
func reduce(state: MainState, action: MainAction) -> MainState { //<-- Error because MainAction is a protocol not a concrete one.
return state
}
}
internal class MainState : BaseState {}
internal protocol MainAction : BaseAction {}
internal protocol BaseState {}
internal protocol BaseAction {}
If I change MainAction from protocol to class, the compile error disappears.
I've searching many articles to understand of this error but failed.
Do I have to pass a concrete parameter(eg. enum, class, struct) in reduce(...) function?
I want to make ReducerImpl can take various action type that conform MainAction.
Is there anyone who can give me explain about that error and why the Swift adopt this kind of rule.