Skip to content

Commit cf608c0

Browse files
authored
Merge pull request swiftlang#30752 from DougGregor/codable-iuo-crash
2 parents a317b87 + 9a37a2a commit cf608c0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ static CodableConformanceType typeConformsToCodable(DeclContext *context,
8282
ProtocolDecl *proto) {
8383
target = context->mapTypeIntoContext(target);
8484

85-
if (isIUO)
86-
return typeConformsToCodable(context, target->getOptionalObjectType(),
85+
if (isIUO) {
86+
return typeConformsToCodable(context,
87+
target->lookThroughSingleOptionalType(),
8788
false, proto);
89+
}
8890

8991
auto conf = TypeChecker::conformsToProtocol(target, proto, context, None);
9092
return conf.isInvalid() ? DoesNotConform : Conforms;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown
2+
3+
// Crash due to codable synthesis with implicitly unwrapped optionals of
4+
// ill-formed types.
5+
// rdar://problem/60985179
6+
struct X: Codable { // expected-error 2{{type 'X' does not conform to protocol}}
7+
var c: Undefined! // expected-error{{use of undeclared type 'Undefined'}}
8+
// expected-note @-1{{does not conform to}}
9+
// expected-note @-2{{does not conform to}}
10+
}

0 commit comments

Comments
 (0)