how can I correct errors?!
domain module, contains all abstracts
//MARK: - Domain
protocol TypeB {
associatedtype P
func makeP() -> P
init()
}
protocol TypeA {
associatedtype P
associatedtype B: TypeB
func makeP() -> P
init(objB: B)
}
protocol FirstTargetFabricType {
func makeB<B: TypeB>() -> B where B.P == Int
}
protocol SecondTargetFabricType {
func makeA<B, A: TypeA>(objcB: B) -> A where A.B == B, A.P == B.P, B.P == Int
}
the first module, for example the module for working with the network
//MARK: - First Target
class ClassB: TypeB {
required init() { }
func makeP() -> Double { return 10 }
}
// error: Cannot convert return expression of type 'ClassB' to return type 'B'
class FirstTargetFabric: FirstTargetFabricType {
func makeB<B: TypeB>() -> B where B.P == Int {
return ClassB()
}
}
the second module, for example the module for working with the storage
//MARK: - SecondTarget
class ClassA<B: TypeB>: TypeA {
let objB: B
required init(objB: B) {
self.objB = objB
}
func makeP() -> B.P { return objB.makeP() }
}
class SecondTargetFabric: SecondTargetFabricType {
func makeA<B, A: TypeA>(objcB: B) -> A where B == A.B, B.P == A.P, B.P == Int {
return A(objB: objcB)
}
}
application target
//MARK: - app
let firstFabric: FirstTargetFabricType = FirstTargetFabric()
let secondFabric: SecondTargetFabricType = SecondTargetFabric()
/// error: Generic parameter 'A' could not be inferred
let res = secondFabric.makeA(objcB: firstFabric.makeB())
I'm trying to make a service loader for pagination. I just want to pass in the class initializer an entity that will go to the network