@@ -99,11 +99,6 @@ static CodableConformanceType typeConformsToCodable(DeclContext *context,
9999// / \param proto The \c ProtocolDecl to check conformance to.
100100static CodableConformanceType
101101varConformsToCodable (DeclContext *DC, VarDecl *varDecl, ProtocolDecl *proto) {
102- auto declInterfaceType = varDecl->getValueInterfaceType ();
103- if (declInterfaceType->hasError ()) {
104- return CodableConformanceType::TypeNotValidated;
105- }
106-
107102 // If the decl doesn't yet have a type, we may be seeing it before the type
108103 // checker has gotten around to evaluating its type. For example:
109104 //
@@ -117,7 +112,8 @@ varConformsToCodable(DeclContext *DC, VarDecl *varDecl, ProtocolDecl *proto) {
117112 // // hasn't yet been evaluated
118113 // }
119114 bool isIUO = varDecl->isImplicitlyUnwrappedOptional ();
120- return typeConformsToCodable (DC, declInterfaceType, isIUO, proto);
115+ return typeConformsToCodable (DC, varDecl->getValueInterfaceType (), isIUO,
116+ proto);
121117}
122118
123119// / Retrieve the variable name for the purposes of encoding/decoding.
@@ -180,10 +176,18 @@ static bool validateCodingKeysEnum(DerivedConformance &derived,
180176 propertiesAreValid = false ;
181177 continue ;
182178 }
183-
179+
180+ auto varDecl = it->second ;
181+
182+ // If the element declaration type has an error, let's skip conformance
183+ // validation because this was caused by another problem that will
184+ // produce a diagnostic elsewhere anyway.
185+ if (varDecl->getInterfaceType ()->hasError ())
186+ continue ;
187+
184188 // We have a property to map to. Ensure it's {En,De}codable.
185189 auto conformance =
186- varConformsToCodable (conformanceDC, it-> second , derived.Protocol );
190+ varConformsToCodable (conformanceDC, varDecl , derived.Protocol );
187191 switch (conformance) {
188192 case Conforms:
189193 // The property was valid. Remove it from the list.
@@ -222,9 +226,12 @@ static bool validateCodingKeysEnum(DerivedConformance &derived,
222226 if (!properties.empty () &&
223227 derived.Protocol ->isSpecificProtocol (KnownProtocolKind::Decodable)) {
224228 for (auto it = properties.begin (); it != properties.end (); ++it) {
229+ auto *varDecl = it->second ;
230+ if (varDecl->getInterfaceType ()->hasError ())
231+ continue ;
232+
225233 // If the var is default initializable, then it need not have an explicit
226234 // initial value.
227- auto *varDecl = it->second ;
228235 if (auto pbd = varDecl->getParentPatternBinding ()) {
229236 if (pbd->isDefaultInitializable ())
230237 continue ;
@@ -361,6 +368,12 @@ static EnumDecl *synthesizeCodingKeysEnum(DerivedConformance &derived) {
361368 for (auto *varDecl : target->getStoredProperties ()) {
362369 if (!varDecl->isUserAccessible ())
363370 continue ;
371+
372+ // If the synthetized element type has an error, let's skip conformance
373+ // validation because this was caused by another problem that will
374+ // produce a diagnostic elsewhere anyway.
375+ if (varDecl->getInterfaceType ()->hasError ())
376+ continue ;
364377
365378 // Despite creating the enum in the context of the type, we're
366379 // concurrently checking the variables for the current protocol
0 commit comments