|
27 | 27 | #include "swift/AST/ConformanceLookup.h"
|
28 | 28 | #include "swift/AST/Decl.h"
|
29 | 29 | #include "swift/AST/DiagnosticsClangImporter.h"
|
| 30 | +#include "swift/AST/DiagnosticsSema.h" |
30 | 31 | #include "swift/AST/ExistentialLayout.h"
|
31 | 32 | #include "swift/AST/Expr.h"
|
32 | 33 | #include "swift/AST/GenericEnvironment.h"
|
|
70 | 71 | #include "clang/AST/Type.h"
|
71 | 72 | #include "clang/Basic/Specifiers.h"
|
72 | 73 | #include "clang/Basic/TargetInfo.h"
|
73 |
| -#include "clang/Sema/SemaDiagnostic.h" |
74 | 74 | #include "clang/Lex/Preprocessor.h"
|
75 | 75 | #include "clang/Sema/Lookup.h"
|
| 76 | +#include "clang/Sema/SemaDiagnostic.h" |
76 | 77 |
|
77 | 78 | #include "llvm/ADT/STLExtras.h"
|
78 | 79 | #include "llvm/ADT/SmallBitVector.h"
|
@@ -10113,8 +10114,8 @@ void ClangImporter::Implementation::startedImportingEntity() {
|
10113 | 10114 | }
|
10114 | 10115 |
|
10115 | 10116 | /// Look up associated type requirements in the conforming type.
|
10116 |
| -static void finishTypeWitnesses( |
10117 |
| - NormalProtocolConformance *conformance) { |
| 10117 | +static void finishTypeWitnesses(NormalProtocolConformance *conformance, |
| 10118 | + ASTContext &ctx) { |
10118 | 10119 | auto *dc = conformance->getDeclContext();
|
10119 | 10120 | auto nominal = dc->getSelfNominalTypeDecl();
|
10120 | 10121 |
|
@@ -10158,11 +10159,11 @@ static void finishTypeWitnesses(
|
10158 | 10159 | }
|
10159 | 10160 |
|
10160 | 10161 | if (!satisfied) {
|
10161 |
| - ABORT([&](auto &out) { |
10162 |
| - out << "Cannot look up associated type for imported conformance:\n"; |
10163 |
| - conformance->getType().dump(out); |
10164 |
| - assocType->dump(out); |
10165 |
| - }); |
| 10162 | + // Avoid compiler crash due to missing witness. |
| 10163 | + conformance->setTypeWitness(assocType, ErrorType::get(ctx), assocType); |
| 10164 | + proto->diagnose(diag::type_does_not_conform, selfType, |
| 10165 | + proto->getDeclaredType()); |
| 10166 | + proto->diagnose(diag::no_witnesses_type, assocType); |
10166 | 10167 | }
|
10167 | 10168 | }
|
10168 | 10169 | }
|
@@ -10210,7 +10211,7 @@ void ClangImporter::Implementation::finishNormalConformance(
|
10210 | 10211 | auto *proto = conformance->getProtocol();
|
10211 | 10212 | PrettyStackTraceConformance trace("completing import of", conformance);
|
10212 | 10213 |
|
10213 |
| - finishTypeWitnesses(conformance); |
| 10214 | + finishTypeWitnesses(conformance, SwiftContext); |
10214 | 10215 |
|
10215 | 10216 | // Imported conformances to @objc protocols also require additional
|
10216 | 10217 | // initialization to complete the requirement to witness mapping.
|
|
0 commit comments