@@ -2208,6 +2208,16 @@ getObjCObjectRepresentable(Type type, const DeclContext *dc) {
2208
2208
static std::pair<ForeignRepresentableKind, ProtocolConformance *>
2209
2209
getForeignRepresentable (Type type, ForeignLanguage language,
2210
2210
const DeclContext *dc) {
2211
+ // Local function that simply produces a failing result.
2212
+ auto failure = []() -> std::pair<ForeignRepresentableKind,
2213
+ ProtocolConformance *> {
2214
+ return { ForeignRepresentableKind::None, nullptr };
2215
+ };
2216
+
2217
+ // If type has an error let's fail early.
2218
+ if (type->hasError ())
2219
+ return failure ();
2220
+
2211
2221
// Look through one level of optional type, but remember that we did.
2212
2222
bool wasOptional = false ;
2213
2223
if (auto valueType = type->getOptionalObjectType ()) {
@@ -2222,12 +2232,6 @@ getForeignRepresentable(Type type, ForeignLanguage language,
2222
2232
return { representable, nullptr };
2223
2233
}
2224
2234
2225
- // Local function that simply produces a failing result.
2226
- auto failure = []() -> std::pair<ForeignRepresentableKind,
2227
- ProtocolConformance *> {
2228
- return { ForeignRepresentableKind::None, nullptr };
2229
- };
2230
-
2231
2235
// Function types.
2232
2236
if (auto functionType = type->getAs <FunctionType>()) {
2233
2237
// Cannot handle throwing functions.
0 commit comments