Skip to content

Commit ba0f1e9

Browse files
committed
[AST] Adjust getBridgedToObjC to produce only valid witness types
`getBridgedToObjC` was allowed to produce a dependent member type with invalid base (`<<error type>>`) if Objective-C import is broken, which results in a crash during member lookup on that type by the constraint solver. Resolves: rdar://104354485
1 parent ffac122 commit ba0f1e9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/AST/ASTContext.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5464,7 +5464,10 @@ Type ASTContext::getBridgedToObjC(const DeclContext *dc, Type type,
54645464
*bridgedValueType = type;
54655465

54665466
// Find the Objective-C class type we bridge to.
5467-
return conformance.getTypeWitnessByName(type, Id_ObjectiveCType);
5467+
Type witnessTy = conformance.getTypeWitnessByName(type, Id_ObjectiveCType);
5468+
// If Objective-C import is broken, witness type would be a dependent member
5469+
// with `<<error type>>` base.
5470+
return (witnessTy && !witnessTy->hasError()) ? witnessTy : Type();
54685471
}
54695472

54705473
// Do we conform to Error?

0 commit comments

Comments
 (0)