mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
A recent change to witness matching in #32578 suddenly made the following construction illegal: // File1.swift enum MyEnumInAnotherFile { /**/ } // File2.swift extension MyEnumInAnotherFile { static var allCases: [MyEnumInAnotherFile] { /**/ } } Because it was no longer possible to derive the type witness for `AllCases`. This is because, when inference ran before synthesis, we would use the value witness to pick out the type witness and thus had no need for synthesis. Now that we run synthesis first, we ought to just allow deriving type witnesses across files, but still ban deriving value witnesses. In general, if you can utter a type in a different file to extend it, you should be able to see the requirements necessary to derive a default type witness. rdar://66279278, rdar://66279375, rdar://66279384, rdar://66279415, rdar://66279503
36 lines
758 B
Swift
36 lines
758 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 {
|
|
// expected-note@-1 {{type declared here}}
|
|
case A = "a"
|
|
}
|
|
enum AlsoFromOtherFile : Int {
|
|
case A = 0
|
|
}
|
|
enum YetAnotherFromOtherFile: Float {
|
|
case A = 0.0
|
|
}
|
|
|
|
enum OtherFileNonconforming {
|
|
case A(Int)
|
|
}
|
|
enum YetOtherFileNonconforming {
|
|
// expected-note@-1 {{type declared here}}
|
|
case A(Int)
|
|
}
|
|
|
|
enum GenericOtherFileNonconforming<T> {
|
|
// expected-note@-1 {{type declared here}}
|
|
case A(T)
|
|
}
|
|
|
|
protocol ImplierOther: Equatable {}
|
|
extension ImpliedMain: ImplierMain {}
|
|
enum ImpliedOther: ImplierOther {
|
|
case a(Int)
|
|
}
|
|
|
|
enum CaseIterableAcrossFiles {
|
|
case A
|
|
}
|