diff --git a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp index 49bc188f8f5a2..31688ef617a9d 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp @@ -1862,6 +1862,7 @@ uint32_t TypeSystemSwiftTypeRef::CollectTypeInfo( swift_flags |= eTypeHasValue; break; + case Node::Kind::ConstrainedExistential: case Node::Kind::BoundGenericProtocol: case Node::Kind::Protocol: swift_flags |= eTypeHasChildren | eTypeIsStructUnion | eTypeIsProtocol; @@ -3176,6 +3177,7 @@ bool TypeSystemSwiftTypeRef::IsPossibleDynamicType(opaque_compiler_type_t type, switch (node->getKind()) { case Node::Kind::Class: case Node::Kind::BoundGenericClass: + case Node::Kind::ConstrainedExistential: case Node::Kind::Protocol: case Node::Kind::ProtocolList: case Node::Kind::ProtocolListWithClass: @@ -3186,6 +3188,7 @@ bool TypeSystemSwiftTypeRef::IsPossibleDynamicType(opaque_compiler_type_t type, case Node::Kind::Enum: case Node::Kind::BoundGenericEnum: return true; + case Node::Kind::BoundGenericStructure: { if (node->getNumChildren() < 2) return false; @@ -5030,6 +5033,7 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue( is_base_class); return false; } + case Node::Kind::ConstrainedExistential: case Node::Kind::ProtocolList: return false; default: diff --git a/lldb/test/API/lang/swift/constrained_existential/Makefile b/lldb/test/API/lang/swift/constrained_existential/Makefile new file mode 100644 index 0000000000000..2a69023633b34 --- /dev/null +++ b/lldb/test/API/lang/swift/constrained_existential/Makefile @@ -0,0 +1,3 @@ +SWIFT_SOURCES := main.swift + +include Makefile.rules diff --git a/lldb/test/API/lang/swift/constrained_existential/TestSwiftConstrainedExistential.py b/lldb/test/API/lang/swift/constrained_existential/TestSwiftConstrainedExistential.py new file mode 100644 index 0000000000000..62dacf4e00e8f --- /dev/null +++ b/lldb/test/API/lang/swift/constrained_existential/TestSwiftConstrainedExistential.py @@ -0,0 +1,26 @@ +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftConstrainedExistential(lldbtest.TestBase): + @swiftTest + def test(self): + """Test constrained existential types""" + + self.build() + lldbutil.run_to_source_breakpoint(self, "break here", + lldb.SBFileSpec("main.swift")) + s0 = self.frame().FindVariable("s0") + self.assertEqual(s0.GetStaticValue().GetNumChildren(), 3+1+2) + self.assertEqual(s0.GetNumChildren(), 1) + i = s0.GetChildMemberWithName("i") + lldbutil.check_variable(self, i, value='23') + + s = self.frame().FindVariable("s") + s = s.GetChildAtIndex(0) + self.assertEqual(s.GetStaticValue().GetNumChildren(), 6) + self.assertEqual(s.GetNumChildren(), 1) + i = s.GetChildMemberWithName("i") + lldbutil.check_variable(self, i, value='23') diff --git a/lldb/test/API/lang/swift/constrained_existential/main.swift b/lldb/test/API/lang/swift/constrained_existential/main.swift new file mode 100644 index 0000000000000..1efc0edc914a5 --- /dev/null +++ b/lldb/test/API/lang/swift/constrained_existential/main.swift @@ -0,0 +1,28 @@ +protocol P1 { + associatedtype U + func get1() -> U +} + +protocol P2 { + associatedtype V + func get2() -> V +} + +struct Impl : P1, P2<(Int, Int)> { + let i = 23 + func get1() -> Int { return i } + func get2() -> (Int, Int) { return (4, 2) } +} + +struct S { + let s: any P1 & P2<(T, T)> +} + +func f() { + let s0: any P1 & P2<(Int, Int)> = Impl() + let s = S(s: Impl()) + print("break here") +} + +f() + diff --git a/lldb/test/API/lang/swift/symbolic_extended_existential/Makefile b/lldb/test/API/lang/swift/symbolic_extended_existential/Makefile new file mode 100644 index 0000000000000..2a69023633b34 --- /dev/null +++ b/lldb/test/API/lang/swift/symbolic_extended_existential/Makefile @@ -0,0 +1,3 @@ +SWIFT_SOURCES := main.swift + +include Makefile.rules diff --git a/lldb/test/API/lang/swift/symbolic_extended_existential/TestSwiftSymbolicExtendedExistential.py b/lldb/test/API/lang/swift/symbolic_extended_existential/TestSwiftSymbolicExtendedExistential.py new file mode 100644 index 0000000000000..0d3adf33f3150 --- /dev/null +++ b/lldb/test/API/lang/swift/symbolic_extended_existential/TestSwiftSymbolicExtendedExistential.py @@ -0,0 +1,48 @@ +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbtest as lldbtest +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftSymbolicExtendedExistential(lldbtest.TestBase): + + @swiftTest + def test(self): + """Test symbolic extended existentials""" + self.build() + lldbutil.run_to_source_breakpoint( + self, 'break here', lldb.SBFileSpec('main.swift')) + + if self.TraceOn(): + self.runCmd("v -d run -L s") + frame = self.frame() + var_s = frame.FindVariable("s") + var_s_l0 = var_s.GetChildMemberWithName("l0") + var_s_l1 = var_s.GetChildMemberWithName("l1") + var_s_l2 = var_s.GetChildMemberWithName("l2") + var_s_l3 = var_s.GetChildMemberWithName("l3") + var_s_l4 = var_s.GetChildMemberWithName("l4") + var_s_l5 = var_s.GetChildMemberWithName("l5") + var_s_l6 = var_s.GetChildMemberWithName("l6") + lldbutil.check_variable(self, var_s_l0, value="0") + lldbutil.check_variable(self, var_s_l1, value="10") + lldbutil.check_variable(self, var_s_l2, value="20") + lldbutil.check_variable(self, var_s_l3, value="30") + lldbutil.check_variable(self, var_s_l4, value="40") + lldbutil.check_variable(self, var_s_l5, value="50") + lldbutil.check_variable(self, var_s_l6, value="60") + var_s_s1 = var_s.GetChildMemberWithName("s1") + var_s_s2 = var_s.GetChildMemberWithName("s2") + var_s_s3 = var_s.GetChildMemberWithName("s3") + var_s_s4 = var_s.GetChildMemberWithName("s4") + var_s_s5 = var_s.GetChildMemberWithName("s5") + var_s_s6 = var_s.GetChildMemberWithName("s6") + lldbutil.check_variable(self, var_s_s1, use_dynamic=True, summary="1...1") + lldbutil.check_variable(self, var_s_s2, use_dynamic=True, summary="1...200") + lldbutil.check_variable(self, var_s_s3, use_dynamic=True, summary="1...2") + lldbutil.check_variable(self, var_s_s4, use_dynamic=True, summary="nil") + lldbutil.check_variable(self, var_s_s5, use_dynamic=True, typename="a.C") + # FIXME: + # lldbutil.check_variable(self, var_s_s6, use_dynamic=True, summary="Int") + + self.expect("expression -- s.s1", substrs=['1...1']) diff --git a/lldb/test/API/lang/swift/symbolic_extended_existential/main.swift b/lldb/test/API/lang/swift/symbolic_extended_existential/main.swift new file mode 100644 index 0000000000000..56879e48ab1b3 --- /dev/null +++ b/lldb/test/API/lang/swift/symbolic_extended_existential/main.swift @@ -0,0 +1,25 @@ +class C {} + +struct S { + let l0 = 0 + let s1 : any Sequence = 1...1 + let l1 = 10 + let s2 : any Sequence = 1...200 + let l2 = 20 + let s3 : (any Sequence)? = 1...2 + let l3 = 30 + let s4 : (any Sequence)? = nil + let l4 = 40 + let s5 : any AnyObject = C() + let l5 = 50 + let s6 : any Any.Type = Int.self + let l6 = 60 +} + +func main() { + var s = S() + print("break here") +} + +main() +