@@ -8987,6 +8987,8 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
8987
8987
void TypeChecker::synthesizeMemberForLookup (NominalTypeDecl *target,
8988
8988
DeclName member) {
8989
8989
auto baseName = member.getBaseName ();
8990
+ if (baseName != Context.Id_CodingKeys )
8991
+ return ;
8990
8992
8991
8993
// Checks whether the target conforms to the given protocol. If the
8992
8994
// conformance is incomplete, force the conformance.
@@ -9011,48 +9013,20 @@ void TypeChecker::synthesizeMemberForLookup(NominalTypeDecl *target,
9011
9013
return false ;
9012
9014
};
9013
9015
9014
- if (member.isSimpleName () && !baseName.isSpecial ()) {
9015
- if (baseName.getIdentifier () == Context.Id_CodingKeys ) {
9016
- // CodingKeys is a special type which may be synthesized as part of
9017
- // Encodable/Decodable conformance. If the target conforms to either
9018
- // protocol and would derive conformance to either, the type may be
9019
- // synthesized.
9020
- // If the target conforms to either and the conformance has not yet been
9021
- // evaluated, then we should do that here.
9022
- //
9023
- // Try to synthesize Decodable first. If that fails, try to synthesize
9024
- // Encodable. If either succeeds and CodingKeys should have been
9025
- // synthesized, it will be synthesized.
9026
- auto *decodableProto = Context.getProtocol (KnownProtocolKind::Decodable);
9027
- auto *encodableProto = Context.getProtocol (KnownProtocolKind::Encodable);
9028
- if (!evaluateTargetConformanceTo (decodableProto))
9029
- (void )evaluateTargetConformanceTo (encodableProto);
9030
- }
9031
- } else {
9032
- auto argumentNames = member.getArgumentNames ();
9033
- if (argumentNames.size () != 1 )
9034
- return ;
9035
-
9036
- auto argumentName = argumentNames.front ();
9037
- if (baseName == DeclBaseName::createConstructor () &&
9038
- argumentName == Context.Id_from ) {
9039
- // init(from:) may be synthesized as part of derived conformance to the
9040
- // Decodable protocol.
9041
- // If the target should conform to the Decodable protocol, check the
9042
- // conformance here to attempt synthesis.
9043
- auto *decodableProto = Context.getProtocol (KnownProtocolKind::Decodable);
9044
- (void )evaluateTargetConformanceTo (decodableProto);
9045
- } else if (!baseName.isSpecial () &&
9046
- baseName.getIdentifier () == Context.Id_encode &&
9047
- argumentName == Context.Id_to ) {
9048
- // encode(to:) may be synthesized as part of derived conformance to the
9049
- // Encodable protocol.
9050
- // If the target should conform to the Encodable protocol, check the
9051
- // conformance here to attempt synthesis.
9052
- auto *encodableProto = Context.getProtocol (KnownProtocolKind::Encodable);
9053
- (void )evaluateTargetConformanceTo (encodableProto);
9054
- }
9055
- }
9016
+ // CodingKeys is a special type which may be synthesized as part of
9017
+ // Encodable/Decodable conformance. If the target conforms to either
9018
+ // protocol and would derive conformance to either, the type may be
9019
+ // synthesized.
9020
+ // If the target conforms to either and the conformance has not yet been
9021
+ // evaluated, then we should do that here.
9022
+ //
9023
+ // Try to synthesize Decodable first. If that fails, try to synthesize
9024
+ // Encodable. If either succeeds and CodingKeys should have been
9025
+ // synthesized, it will be synthesized.
9026
+ auto *decodableProto = Context.getProtocol (KnownProtocolKind::Decodable);
9027
+ auto *encodableProto = Context.getProtocol (KnownProtocolKind::Encodable);
9028
+ if (!evaluateTargetConformanceTo (decodableProto))
9029
+ (void )evaluateTargetConformanceTo (encodableProto);
9056
9030
}
9057
9031
9058
9032
void TypeChecker::defineDefaultConstructor (NominalTypeDecl *decl) {
0 commit comments