Skip to content

Commit d9e38ae

Browse files
committed
Thicken generic metatypes in BindGenericTypeParameters().
Generic metatypes should always be thick and TypeRef::subst() performs the exact same transformation. <rdar://problem/69765047> (cherry picked from commit eaf9f9d)
1 parent 07af5c6 commit d9e38ae

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lldb/source/Target/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,21 @@ SwiftLanguageRuntimeImpl::BindGenericTypeParameters(StackFrame &stack_frame,
14341434
return type;
14351435
});
14361436

1437+
// Thicken generic metatypes. Once substituted, they should always
1438+
// be thick. TypeRef::subst() does the same transformation.
1439+
target_swift_type =
1440+
target_swift_type.transform([](swift::Type type) -> swift::Type {
1441+
using namespace swift;
1442+
const auto thin = MetatypeRepresentation::Thin;
1443+
const auto thick = MetatypeRepresentation::Thick;
1444+
if (auto *metatype = dyn_cast<AnyMetatypeType>(type.getPointer()))
1445+
if (metatype->hasRepresentation() &&
1446+
metatype->getRepresentation() == thin &&
1447+
metatype->getInstanceType()->hasTypeParameter())
1448+
return MetatypeType::get(metatype->getInstanceType(), thick);
1449+
return type;
1450+
});
1451+
14371452
while (target_swift_type->hasOpaqueArchetype()) {
14381453
auto old_type = target_swift_type;
14391454
target_swift_type = target_swift_type.subst(

lldb/test/API/lang/swift/expression/static/TestSwiftExpressionsInClassFunctions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,14 @@ def test_expressions_in_class_functions(self):
7676
self.check_expression("i", str(i), False)
7777
if i == 6:
7878
self.check_expression("self", "a.H<Int>")
79+
frame = threads[0].GetFrameAtIndex(0)
80+
lldbutil.check_variable(self, frame.FindVariable("self"),
81+
use_dynamic=True,
82+
# FIXME: This should be '@thick a.H<Swift.Int>.Type'
83+
# but valobj.GetDynamicValue(lldb.eDynamicCanRunTarget)
84+
# doesn't seem to do its job.
85+
# rdar://problem/69889462
86+
typename='@thin a.H<τ_0_0>.Type')
87+
7988
self.runCmd("continue")
8089

0 commit comments

Comments
 (0)