Skip to content

Commit 2e5f98d

Browse files
authored
Merge pull request #72392 from rintaro/refactoring-codable-sr72387
[Refactoring] Skip failed witness decls in "add codable implementation"
2 parents 81812ea + 7177055 commit 2e5f98d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/Refactoring/AddExplicitCodableImplementation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class AddCodableContext {
133133
kind == KnownProtocolKind::Decodable) {
134134
for (auto requirement : protocol->getProtocolRequirements()) {
135135
auto witness = conformance->getWitnessDecl(requirement);
136-
if (witness->isSynthesized()) {
136+
if (witness && witness->isSynthesized()) {
137137
Printer.printNewline();
138138
witness->print(Printer, Options);
139139
Printer.printNewline();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
struct Foo: Codable {
3+
var other: Unknown
4+
5+
private enum CodingKeys: CodingKey {
6+
case other
7+
}
8+
}
9+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %empty-directory(%t.result)
2+
3+
// RUN: %refactor -add-explicit-codable-implementation -source-filename %s -pos=%(line + 2):8 > %t.result/invalid_member.swift
4+
// RUN: diff -u %S/Outputs/has_error/invalid_member.swift.expected %t.result/invalid_member.swift
5+
struct Foo: Codable {
6+
var other: Unknown
7+
}
8+

0 commit comments

Comments
 (0)