Open
Description
Description
Compiler Error: Cannot find type 'CodingKeys' in scope
when CodingKeys
is used as a parameter in a static
or instance
method in the main type definition of an Enum
.
Steps To Reproduce
- Xcode 14.1 playground
- This code does NOT compile:
enum SomeCodableEnum: Codable {
case someCase
// Compiler Error: "Cannot find type 'CodingKeys' in scope"
private static func print0(_ codingKeys: CodingKeys.Type) {}
// Compiler Error: "Cannot find type 'CodingKeys' in scope"
private func print1(_ codingKeys: CodingKeys.Type) {}
}
- This code DOES compile:
enum SomeCodableEnum: Codable {
case someCase
static func print0() {
print(CodingKeys.self)
}
func print1() {
print(CodingKeys.self)
}
}
extension SomeCodableEnum {
private static func print2(_ codingKeys: CodingKeys.Type) {
print(codingKeys)
}
private func print3(_ codingKeys: CodingKeys.Type) {
print(codingKeys)
}
}
...
Expected behavior
Code should compile when CodingKeys
is used as a parameter in the definition of a static
or instance
method in the main type definition of an Enum
.
Environment (please fill out the following information)
- OS: macOS 12.6.1 (21G217)
- Xcode Version/Tag/Branch: Xcode 14.1 (14B47B)
Additional context
It appears that structs
and classes
do not have this issue.
Metadata
Metadata
Assignees
Labels
Area → standard library: `Codable` and co.A deviation from expected or documented behavior. Also: expected but undesirable behavior.The Swift compiler itselfFeature → protocol: protocol conformancesFeature → protocol → conformances: derived conformances aka synthesized conformancesArea → compiler: Semantic analysis