Skip to content

Commit ffe79e0

Browse files
committed
[Codable] Remove compiler hack faking conditional conformances.
The Codable synthesis code was checking the conditional requirements of Optional/Array/Set/Dictionary's Codable conformances, which had to be unconditional. Now that they are properly conditional conformances, we no longer need the hack. Thanks to @itaiferber for pointing this out!
1 parent 89343e2 commit ffe79e0

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,7 @@ static CodableConformanceType typeConformsToCodable(TypeChecker &tc,
9898
// Implicitly unwrapped optionals need to be unwrapped;
9999
// ImplicitlyUnwrappedOptional does not need to conform to Codable directly
100100
// -- only its inner type does.
101-
if (nominalTypeDecl == tc.Context.getImplicitlyUnwrappedOptionalDecl() ||
102-
// FIXME: Remove the following when conditional conformance lands.
103-
// Some generic types in the stdlib currently conform to Codable even
104-
// when the type they are generic on does not [Optional, Array, Set,
105-
// Dictionary]. For synthesizing conformance, we don't want to
106-
// consider these types as Codable if the nested type is not Codable.
107-
// Look through the generic type parameters of these types recursively
108-
// to avoid synthesizing code that will crash at runtime.
109-
//
110-
// We only want to look through generic params for these types; other
111-
// types may validly conform to Codable even if their generic param
112-
// types do not.
113-
nominalTypeDecl == tc.Context.getOptionalDecl() ||
114-
nominalTypeDecl == tc.Context.getArrayDecl() ||
115-
nominalTypeDecl == tc.Context.getSetDecl() ||
116-
nominalTypeDecl == tc.Context.getDictionaryDecl()) {
101+
if (nominalTypeDecl == tc.Context.getImplicitlyUnwrappedOptionalDecl()) {
117102
for (auto paramType : genericType->getGenericArgs()) {
118103
if (typeConformsToCodable(tc, context, paramType, proto) != Conforms)
119104
return DoesNotConform;

0 commit comments

Comments
 (0)