mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
If a conformance to a protocol is implied by several other
conformances (i.e. protocol P: Equatable {} and protocol Q: Equatable {} and a
type declares conformance to both P and Q), we should choose a source that's in
the same file as the type, if we can, because automatic synthesis of
conformances (for Equatable, Hashable, etc.) only works in that case.
Fixes rdar://problem/41852654.
29 lines
682 B
Swift
29 lines
682 B
Swift
// Note that for the test to be effective, each of these structs must only have
|
|
// its Equatable or Hashable conformance referenced /once/ in the primary file.
|
|
struct FromOtherFile: Hashable {
|
|
let v: String
|
|
}
|
|
struct AlsoFromOtherFile: Hashable {
|
|
let v: Int
|
|
}
|
|
struct YetAnotherFromOtherFile: Hashable {
|
|
let v: Float
|
|
}
|
|
|
|
struct OtherFileNonconforming {
|
|
let v: String
|
|
}
|
|
struct YetOtherFileNonconforming {
|
|
// expected-note@-1{{type declared here}}
|
|
let v: String
|
|
}
|
|
|
|
struct GenericOtherFileNonconforming<T> {
|
|
// expected-note@-1{{type declared here}}
|
|
let v: T
|
|
}
|
|
|
|
protocol ImplierOther: Equatable {}
|
|
extension ImpliedMain: ImplierOther {}
|
|
struct ImpliedOther: ImplierOther {}
|