Files
swift-mirror/test/Sema/Inputs/enum_equatable_hashable_other.swift
Jordan Rose 9418b9cfd4 [Type Checker] Try harder to synthesize enum Equatable conformance on demand.
If either parameter to == has a known concrete type at constraint generation
time, see if that type is a nominal that can derive its conformance to
Equatable. If so, do so, and then add that == to the overload set.
(It may already be there, but that's okay -- it will get uniqued later.)

This isn't perfect because it relies on one of the parameters to == having
a concrete type /before/ constraint solving. There are plenty of reasons
why that wouldn't happen. But this at least fixes the common case, and
breaking the expression up into multiple lines is a less distasteful
workaround than replacing (x == .Value) with !(x != .Value). I've added a
test case that should work but doesn't that we can revisit later.

rdar://problem/18073705

Swift SVN r21557
2014-08-29 01:10:06 +00:00

11 lines
305 B
Swift

// Note that for the test to be effective, each of these enums must only have
// its Equatable or Hashable conformance referenced /once/ in the primary file.
enum FromOtherFile : String {
case A = "a"
}
enum AlsoFromOtherFile : Int {
case A = 0
}
enum YetAnotherFromOtherFile: Float {
case A = 0.0
}