@@ -4180,7 +4180,7 @@ void SwiftASTContext::CacheDemangledTypeFailure(ConstString name) {
4180
4180
// / What we should really do is only mangle AST types in DebugInfo, but that
4181
4181
// / requires some more plumbing on the Swift side to properly handle generic
4182
4182
// / specializations.
4183
- swift::Type convertSILFunctionTypesToASTFunctionTypes (swift::Type t) {
4183
+ static swift::Type ConvertSILFunctionTypesToASTFunctionTypes (swift::Type t) {
4184
4184
return t.transform ([](swift::Type t) -> swift::Type {
4185
4185
if (auto *silFn = t->getAs <swift::SILFunctionType>())
4186
4186
return swift::FunctionType::get ({}, t->getASTContext ().TheEmptyTupleType );
@@ -4300,14 +4300,18 @@ swift::TypeBase *SwiftASTContext::ReconstructType(ConstString mangled_typename,
4300
4300
.getPointer ();
4301
4301
4302
4302
if (found_type) {
4303
- found_type =
4304
- convertSILFunctionTypesToASTFunctionTypes (found_type).getPointer ();
4305
- CacheDemangledType (mangled_typename, found_type);
4306
- CompilerType result_type = ToCompilerType (found_type);
4307
- assert (&found_type->getASTContext () == ast_ctx);
4303
+ swift::TypeBase *ast_type =
4304
+ ConvertSILFunctionTypesToASTFunctionTypes (found_type).getPointer ();
4305
+ // This transformation is lossy: all SILFunction types are mapped
4306
+ // to the same AST type. We thus cannot cache the result, since
4307
+ // the mapping isn't bijective.
4308
+ if (ast_type == found_type)
4309
+ CacheDemangledType (mangled_typename, ast_type);
4310
+ CompilerType result_type = ToCompilerType (ast_type);
4311
+ assert (&ast_type->getASTContext () == ast_ctx);
4308
4312
LOG_PRINTF (LIBLLDB_LOG_TYPES, " (\" %s\" ) -- found %s" , mangled_cstr,
4309
4313
result_type.GetTypeName ().GetCString ());
4310
- return found_type ;
4314
+ return ast_type ;
4311
4315
}
4312
4316
4313
4317
LOG_PRINTF (LIBLLDB_LOG_TYPES, " (\" %s\" ) -- not found" , mangled_cstr);
0 commit comments