IRGen: Work around runtime bug demangling associated types of opaque types.

The Swift 5.1 runtime (and master, for the time being) do not successfully demangle this mangling,
so for the time being, fall back to open-coded metadata access in this case. Workaround for
rdar://problem/54084733.
This commit is contained in:
Joe Groff
2019-08-08 10:31:48 -07:00
parent 1533a84b63
commit e6bc3e7adf
2 changed files with 54 additions and 1 deletions

View File

@@ -1905,6 +1905,19 @@ static bool shouldAccessByMangledName(IRGenModule &IGM, CanType type) {
}
}
// The Swift 5.1 runtime fails to demangle associated types of opaque types.
auto hasNestedOpaqueArchetype = type.findIf([](CanType sub) -> bool {
if (auto archetype = dyn_cast<NestedArchetypeType>(sub)) {
if (isa<OpaqueTypeArchetypeType>(archetype->getRoot())) {
return true;
}
}
return false;
});
if (hasNestedOpaqueArchetype)
return false;
return true;
// The visitor below can be used to fine-tune a heuristic to decide whether