Avatar
[omochi@omochi-iMac swhash]$ cat b.swift struct Box<T> { let value: T } extension Box: Equatable where T: Equatable { static func == (lhs: Box, rhs: Box) -> Bool { return lhs.value == rhs.value } } print(Box(value: 1) == Box(value: 1)) print(Box(value: 1) == Box(value: 2)) print(Box(value: Box(value: 1)) == Box(value: Box(value: 1))) print(Box(value: Box(value: 1)) == Box(value: Box(value: 2))) [omochi@omochi-iMac swhash]$ swift -enable-experimental-conditional-conformances b.swift true false true false
10:07 AM
masterのほうは動いた。
10:07 AM
[omochi@omochi-iMac swhash]$ swift b.swift b.swift:11:21: error: ambiguous use of operator '==' print(Box(value: 1) == Box(value: 1)) ^ b.swift:6:17: note: found this candidate static func == (lhs: Box, rhs: Box) -> Bool { ^ Swift.Equatable:149:24: note: found this candidate public static func == (lhs: Self, rhs: Self) -> Bool ^ b.swift:12:21: error: ambiguous use of operator '==' print(Box(value: 1) == Box(value: 2)) ^ b.swift:6:17: note: found this candidate static func == (lhs: Box, rhs: Box) -> Bool { ^ Swift.Equatable:149:24: note: found this candidate public static func == (lhs: Self, rhs: Self) -> Bool ^ b.swift:13:33: error: ambiguous use of operator '==' print(Box(value: Box(value: 1)) == Box(value: Box(value: 1))) ^ b.swift:6:17: note: found this candidate static func == (lhs: Box, rhs: Box) -> Bool { ^ Swift.Equatable:149:24: note: found this candidate public static func == (lhs: Self, rhs: Self) -> Bool ^ b.swift:14:33: error: ambiguous use of operator '==' print(Box(value: Box(value: 1)) == Box(value: Box(value: 2))) ^ b.swift:6:17: note: found this candidate static func == (lhs: Box, rhs: Box) -> Bool { ^ Swift.Equatable:149:24: note: found this candidate public static func == (lhs: Self, rhs: Self) -> Bool
10:07 AM
4.1のほうはたしかにダメですね。型定義は通るけど == の呼び出しが死んじゃった