Hello, code similar to the code below used to work on earlier versions of Swift 5.
protocol Composable {
associatedtype Root
}
struct Component<Root> : Composable {
typealias Root = Root
}
struct TupleComponent<Root, A, B> : Composable where A : Composable, B : Composable, A.Root == Root, B.Root == Root {
typealias Root = Root
init(a: A, b: B) {}
}
@_functionBuilder
struct Builder<Root> {
public static func buildBlock<A>(_ a: A) -> A where A : Composable, A.Root == Root {
return a
}
public static func buildBlock<A, B>(_ a: A, _ b: B) -> TupleComponent<Root, A, B> where A : Composable, B : Composable, A.Root == Root, B.Root == Root {
return TupleComponent(a: a, b: b)
}
}
struct Schema<Root> {
init<Component>(@Builder<Root> content: () -> Component) where Component : Composable, Component.Root == Root {}
}
Schema<Bool> {
Component()
}
Schema<String> {
Component() // Generic parameter 'Root' could not be inferred.
Component() // Generic parameter 'Root' could not be inferred.
}
Basically the compiler was able to infer the generic parameters of all children of a parent type given that the parent's generic parameters were explicitly set. I wonder if this is actually a regression or if I should be defining the function builder in another way. I believe @John_McCall and @Douglas_Gregor are the main authors of this feature? Would both of you or anyone else with knowledge about function builders be able to help me solve this? Otherwise, maybe acknowledge that the code above should still be working as it did before? Thank you!