Result builder does not implement 'buildLimitedAvailability'; this code may crash on earlier versions of the OS

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

Notice that the return type of buildLimitedAvailability is still [AnyMyType<HugeHashable>], meaning the HugeHashable type is still implicated on older versions of iOS. In order for it to work properly, buildLimitedAvailability would have to have a signature like e.g.

public static
func buildLimitedAvailability<T: Hashable>(_ component: [AnyMyType<T>]) -> [AnyMyType<AnyHashable>]

The diagnosis could definitely be improved.

Oh, that makes sense actually. Not the error description in Xcode, but the fact the result type is still the unavailable type. Cheers!

The reason I have the identifier type in the built array is I want the compiler to ensure all identifiers are of the same type, even if later on, type is further erased out of that too. And since users can’t mix identifier types, the above error isn’t really something to worry about.

Thanks!