[Refactoring] Skip failed witness decls in "add codable implementation"

When there are problems in the properties in the target type, witness
methods may not be synthesized. Don't try to add such methods.

https://github.com/apple/swift/issues/72387
This commit is contained in:
Rintaro Ishizaki
2024-03-18 23:45:59 +09:00
parent 5d6ce704dd
commit 7177055bdc
3 changed files with 18 additions and 1 deletions

View File

@@ -133,7 +133,7 @@ class AddCodableContext {
kind == KnownProtocolKind::Decodable) {
for (auto requirement : protocol->getProtocolRequirements()) {
auto witness = conformance->getWitnessDecl(requirement);
if (witness->isSynthesized()) {
if (witness && witness->isSynthesized()) {
Printer.printNewline();
witness->print(Printer, Options);
Printer.printNewline();