Skip to content

[SR-5853] Properties with a protocol type that conforms to Codable cannot be synthesized for Codable conformance #48423

@swift-ci

Description

@swift-ci
Previous ID SR-5853
Radar None
Original Reporter fruitcoder (JIRA User)
Type Bug
Status Resolved
Resolution Won't Do

Attachment: Download

Environment

Version 9.0 beta 6 (9M214v)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 7780a4010644f566517ae7386749b6a0

Issue Description:

protocol CodableConforming: Codable {}

struct TestStruct: Codable {
  let protocolProp: CodableConforming
}

When a type that conforms to `Codable` has a property whose type is a protocol conforming to `Codable`, the compiler cannot generate an implementation for `Encodable` and `Decodable`.

Moreover, I cannot provide the implementation myself, since the protocol type is insufficient for the generic `decode(:forKey: )` and `encode(:forKey: )` as I get "ambiguous reference to member" errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions