Files
swift-mirror/test/Sema/Inputs/enum_conformance_synthesis_other.swift
Allan Shortlidge b6ee0796c8 AST: Type-check @available attributes before synthesizing CaseIterable.
An `AvailableAttr` written in source with an unrecognized availability domain
is now only marked invalid after type-checking the attribute. This resulted in a
regression where `CaseIterable` synthesis was blocked incorrectly under the
following very narrow circumstances:

1. Every `@available` attribute on the elements of the enum is invalid.
2. The module is being emitted and lazy type-checking is enabled.
3. The enum is public and the only top-level declaration in the file.

Type-checking the attribute was delayed just enough that it would not be
considered invalid by the type the `CaseIterable` conformance was being
synthesized, resulting in a spurious error.

There were zero tests exercising `CaseIterable` synthesis for enums with
elements that have availability requirements, so I added some.

Resolves rdar://144897917.
2025-02-16 12:20:48 -08:00

31 lines
672 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
}
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)
}