The following code compiles in Xcode 11.0, but it won't compile in Xcode 11.2.1, why?
The compile emits an error message " ambiguous reference to member '==' ".
P.S. If I moved the code out of the function-builder block, there is no compile error any more. It seems that the compiler behavior has changed in the function-builder block.
import Foundation
public struct LayoutStmt {
public init() {}
}
public struct LayoutStmtGroup {
public init(stmts: [LayoutStmt]) {}
}
@_functionBuilder
public struct LayoutBuilder {
public static func buildBlock(_ stmts: LayoutStmt...) -> LayoutStmtGroup {
return LayoutStmtGroup(stmts: stmts)
}
}
@discardableResult
public func AutoLayout(@LayoutBuilder builder: () -> LayoutStmtGroup) -> LayoutStmtGroup {
let group = builder()
return group
}
public class Anchor {
public init() {}
}
func ==(anchor: Anchor, value: Double) -> LayoutStmt {
return LayoutStmt()
}
let anchor = Anchor()
AutoLayout {
anchor == 2 // compiler error: ambiguous reference to member '=='
anchor == 3
}
It is ridiculous! I also faced with functionBuilder regression on Nov, 1, 2019 when I updated to Xcode 11.2 from 11.1. I filed a bug [SR-11694] functionBuilder regression! · Issue #54102 · apple/swift · GitHub but it is still not fixed in Xcode 11.3.1! I don't understand why Apple won't fix it! It is common feature which is already used by a lot of libraries!
Apple use it in production with SwiftUI, why I should not use it? I should sit calm and wait for years? Especially if it works fin in Swift 5.1.0 and then by someones broken hands it stops working in 5.1.1...5.1.3 why I should be silent? I really want it to be fixed to use it in my libs.
Yes, Apple uses it in their closed source library. The attribute itself is underscored and the feature has not yet made it through evolution. You can of course use it, but at your own risk.
Yeah that's right that I use it at my own risk since it is underscored, but I definitely can complain that it is stopped working especially if it doesn't work for three month already.
Because it's not officially supported, so, all bets are off if and when it will work at any one time. SwiftUI and Combine, being private Apple frameworks, get released when Xcode/frameworks are released, and it is tested as part of the Xcode release process, which only happens a few times a year. Any other time, you're on your own as to it working from Swift release to Swift release, as you've experienced, until it is an officially support by the open-source team. Yes, if you want consistency over time, you should remain calm and wait for years, if that is what it takes.
No man, this is not how it works in open source. If something is broken in beta I should annoy everyone until it is fixed because only in this case I will get that working soon.