@@ -2315,6 +2315,8 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
2315
2315
child_bitfield_bit_offset, child_is_base_class,
2316
2316
child_is_deref_of_parent, valobj, language_flags);
2317
2317
};
2318
+ auto ast_num_children = m_swift_ast_context->GetNumChildren (
2319
+ ReconstructType (type), omit_empty_base_classes, exe_ctx);
2318
2320
auto impl = [&]() -> CompilerType {
2319
2321
ExecutionContextScope *exe_scope = nullptr ;
2320
2322
if (exe_ctx)
@@ -2334,6 +2336,15 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
2334
2336
if (llvm::StringRef (AsMangledName (type))
2335
2337
.endswith (" sSo18NSNotificationNameaD" ))
2336
2338
return GetTypeFromMangledTypename (ConstString (" $sSo8NSStringCD" ));
2339
+ if (result.GetMangledTypeName ().GetStringRef ().count (' $' ) > 1 &&
2340
+ ast_num_children == runtime->GetNumChildren ({this , type}, valobj))
2341
+ // If available, prefer the AST for private types. Private
2342
+ // identifiers are not ABI; the runtime returns anonymous private
2343
+ // identifiers (using a '$' prefix) which cannot match identifiers
2344
+ // in the AST. Because these private types can't be used in an AST
2345
+ // context, prefer the AST type if available.
2346
+ if (auto ast_type = fallback ())
2347
+ return ast_type;
2337
2348
return result;
2338
2349
}
2339
2350
}
@@ -2432,8 +2443,7 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
2432
2443
// Because the API deals out an index into a list of children we
2433
2444
// can't mix&match between the two typesystems if there is such a
2434
2445
// divergence. We'll need to replace all calls at once.
2435
- if (m_swift_ast_context->GetNumChildren (ReconstructType (type),
2436
- omit_empty_base_classes, exe_ctx) <
2446
+ if (ast_num_children <
2437
2447
runtime->GetNumChildren ({this , type}, valobj).getValueOr (0 ))
2438
2448
return impl ();
2439
2449
0 commit comments