@@ -4156,7 +4156,7 @@ void SwiftASTContext::CacheDemangledTypeFailure(ConstString name) {
4156
4156
// / What we should really do is only mangle AST types in DebugInfo, but that
4157
4157
// / requires some more plumbing on the Swift side to properly handle generic
4158
4158
// / specializations.
4159
- swift::Type convertSILFunctionTypesToASTFunctionTypes (swift::Type t) {
4159
+ static swift::Type ConvertSILFunctionTypesToASTFunctionTypes (swift::Type t) {
4160
4160
return t.transform ([](swift::Type t) -> swift::Type {
4161
4161
if (auto *silFn = t->getAs <swift::SILFunctionType>())
4162
4162
return swift::FunctionType::get ({}, t->getASTContext ().TheEmptyTupleType );
@@ -4276,14 +4276,18 @@ swift::TypeBase *SwiftASTContext::ReconstructType(ConstString mangled_typename,
4276
4276
.getPointer ();
4277
4277
4278
4278
if (found_type) {
4279
- found_type =
4280
- convertSILFunctionTypesToASTFunctionTypes (found_type).getPointer ();
4281
- CacheDemangledType (mangled_typename, found_type);
4282
- CompilerType result_type = ToCompilerType (found_type);
4283
- assert (&found_type->getASTContext () == ast_ctx);
4279
+ swift::TypeBase *ast_type =
4280
+ ConvertSILFunctionTypesToASTFunctionTypes (found_type).getPointer ();
4281
+ // This transformation is lossy: all SILFunction types are mapped
4282
+ // to the same AST type. We thus cannot cache the result, since
4283
+ // the mapping isn't bijective.
4284
+ if (ast_type == found_type)
4285
+ CacheDemangledType (mangled_typename, ast_type);
4286
+ CompilerType result_type = ToCompilerType (ast_type);
4287
+ assert (&ast_type->getASTContext () == ast_ctx);
4284
4288
LOG_PRINTF (LIBLLDB_LOG_TYPES, " (\" %s\" ) -- found %s" , mangled_cstr,
4285
4289
result_type.GetTypeName ().GetCString ());
4286
- return found_type ;
4290
+ return ast_type ;
4287
4291
}
4288
4292
4289
4293
LOG_PRINTF (LIBLLDB_LOG_TYPES, " (\" %s\" ) -- not found" , mangled_cstr);
0 commit comments