Why this code snippet won't compile in Xcode 11.2.1? (compiles in Xcode 11.0)

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
}

@Joe_Groff Can you help to take a look at this issue? Thanks!

If you haven't yet, please file a bug at bugs.swift.org. Thanks for bringing this to our attention!

Hmm, it's working on "master". It may very well be the same issue as in https://bugs.swift.org/browse/SR-11614

I add another (maybe same reason) compile error case in this issue (https://bugs.swift.org/browse/SR-11888). If the improved playground also works on swift master branch, just close the issue. Thanks.

Terms of Service

Privacy Policy

Cookie Policy