Skip to content

Commit 84e1b82

Browse files
authored
Merge pull request #5940 from augusto2112/1013-test-gen-params
[lldb] Add more test cases to TestSwiftNestedGenericClass
2 parents 269a694 + 87a1708 commit 84e1b82

File tree

3 files changed

+67
-6
lines changed

3 files changed

+67
-6
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1644,8 +1644,13 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
16441644
Log *log(GetLog(LLDBLog::Types));
16451645
auto *reflection_ctx = GetReflectionContext();
16461646
const auto *typeref = reflection_ctx->readTypeFromInstance(instance_ptr);
1647-
if (!typeref)
1647+
if (!typeref) {
1648+
if (log) {
1649+
log->Printf("could not read typeref for type: %s\n",
1650+
class_type.GetMangledTypeName().GetCString());
1651+
}
16481652
return false;
1653+
}
16491654
swift::Demangle::Demangler dem;
16501655
swift::Demangle::NodePointer node = typeref->getDemangling(dem);
16511656
class_type_or_name.SetCompilerType(ts.RemangleAsType(dem, node));

lldb/test/API/lang/swift/nested_generic_class/TestSwiftNestedGenericClass.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@
55
import unittest2
66

77

8-
class SwiftNestedGenericClassTest(TestBase):
8+
class TestSwiftNestedGenericClass(TestBase):
99

1010
@swiftTest
1111
def test(self):
1212
"""Tests that a generic class type nested inside another generic class can be resolved correctly from the instance metadata"""
1313
self.build()
14-
lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.swift"))
15-
self.expect("v foo", substrs=["a.A<Int>.B<String>"])
14+
_, process, _, breakpoint = lldbutil.run_to_source_breakpoint(self,
15+
"break here", lldb.SBFileSpec("main.swift"))
16+
self.expect("v self", substrs=["A<Int>.B<String>"])
17+
18+
lldbutil.continue_to_breakpoint(process, breakpoint)
19+
self.expect("v self", substrs=["C.D<Double>"])
20+
21+
lldbutil.continue_to_breakpoint(process, breakpoint)
22+
self.expect("v self", substrs=["F.G<Bool>.H"])
23+
24+
lldbutil.continue_to_breakpoint(process, breakpoint)
25+
self.expect("v self", substrs=["I.J<String, Int>"])
26+
27+
28+
lldbutil.continue_to_breakpoint(process, breakpoint)
29+
self.expect("v self", substrs=["K.L.M<Double, Bool>"])
1630

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,49 @@
11
public class A<T> {
22
public class B<U> {
3+
func f() {
4+
print(1) // break here
5+
}
36
}
47
}
58

6-
let foo = A<Int>.B<String>()
7-
print(1) // break here
9+
class C {
10+
class D<T> {
11+
func f() {
12+
print(1) // break here
13+
}
14+
}
15+
}
16+
17+
class F {
18+
class G<T> {
19+
class H {
20+
func f() {
21+
print(1) // break here
22+
}
23+
}
24+
}
25+
}
26+
27+
class I {
28+
class J<T, U> {
29+
func f() {
30+
print(1) // break here
31+
}
32+
}
33+
}
34+
35+
class K {
36+
class L {
37+
class M<T, U> {
38+
func f() {
39+
print(1) // break here
40+
}
41+
}
42+
}
43+
}
44+
45+
A<Int>.B<String>().f()
46+
C.D<Double>().f()
47+
F.G<Bool>.H().f()
48+
I.J<String, Int>().f()
49+
K.L.M<Double, Bool>().f()

0 commit comments

Comments
 (0)