Hello,
I have the following types:
public
struct MyType<Identifier: Hashable, A, B, C>: Identifiable {
public let id: Identifier
public let a: A
public let b: B
public let c: C
public
init(id: Identifier, a: A, b: B, c: C) {
self.id = id
self.a = a
self.b = b
self.c = c
}
}
public
protocol MyTypeProtocol {}
extension MyType: MyTypeProtocol {}
public
struct AnyMyType<Identifier> {
let base: any MyTypeProtocol
/// Creates a type-erased popup item that wraps the given instance.
/// - Parameter base: A popup item to wrap.
init<A, B, C>(_ base: MyType<Identifier, A, B, C>) {
self.base = base
}
}
@resultBuilder public
struct MyTypeBuilder<Identifier: Hashable> {
public static
func buildBlock(_ components: [AnyMyType<Identifier>]...) -> [AnyMyType<Identifier>] { components.flatMap { $0 } }
public static
func buildExpression<A, B, C>(_ expression: MyType<Identifier, A, B, C>?) -> [AnyMyType<Identifier>] { if let expression { [AnyMyType<Identifier>(expression)] } else { [] } }
public static
func buildOptional(_ component: [AnyMyType<Identifier>]?) -> [AnyMyType<Identifier>] { component ?? [] }
public static
func buildEither(first component: [AnyMyType<Identifier>]) -> [AnyMyType<Identifier>] { component }
public static
func buildEither(second component: [AnyMyType<Identifier>]) -> [AnyMyType<Identifier>] { component }
public static
func buildArray(_ components: [[AnyMyType<Identifier>]]) -> [AnyMyType<Identifier>] { components.flatMap { $0 } }
public static
func buildLimitedAvailability(_ component: [AnyMyType<Identifier>]) -> [AnyMyType<Identifier>] { component }
}
Notice the result build implements buildLimitedAvailability(\_:).
Now, if add the following code:
@available(iOS 26.0, *)
struct HugeHashable: Hashable {
let a = 3
let ba = InlineArray<10, Int>(repeating: 10)
let aab = 3
let baba = 4
let aabab = 3
let bababa = 4
let aababab = 3
let babababa = 4
let aabababab = 3
let bababababa = 4
let aababababab = 3
let babababababa = 4
let aabababababab = 3
static func == (lhs: HugeHashable, rhs: HugeHashable) -> Bool {
false
}
func hash(into hasher: inout Hasher) {
hasher.combine(42)
}
}
build {
if #available(iOS 26.0, *) { //WARNING: Result builder 'MyTypeBuilder<HugeHashable>' does not implement 'buildLimitedAvailability'; this code may crash on earlier versions of the OS
MyType(id: HugeHashable(), a: InlineArray<3, Int>(repeating: 10), b: 1, c: 1)
}
}
Xcode complaints that:
WARNING: Result builder 'MyTypeBuilder<HugeHashable>' does not implement 'buildLimitedAvailability'; this code may crash on earlier versions of the OS
But it’s clearly implemented.
Is this a bug in the compiler, or am I missing something?
Thanks