When I am defining enum:
enum Test: CGFloat {
case zero
}
and two functions that are similar to the following:
func test(_ param: CGFloat) {
print("param - \(param)")
}
func test(_ param: Test) {
print("param - \(param.rawValue)")
}
Issue when I'm trying to use them:
test(Test.zero) <- prints "param - 0"
test(.zero) <- error: ambiguous use of .zero
While I understand that compiler is clashing with two definitions of .zero, I'm trying to pinpoint where it was changed in release notes of Xcode 12.5. Maybe someone can point me in the right direction? As it seems it's working in 12.4.
Note:
It can be fixed by:
- Better design of the API;
- Using
@_disfavoredOverloadas per following conversation.
Possibly a secondary consequence of
You might file a bug because existing code broke, but it has an edge case feel so perhaps it should never have worked. In any case I bet saying
Test.zerospeeds up compilation. This sort of type checking is complicated, as your forum link shows.