Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -3171,6 +3172,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:
Expand All @@ -3181,6 +3183,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;
Expand Down Expand Up @@ -5024,6 +5027,7 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue(
is_base_class);
return false;
}
case Node::Kind::ConstrainedExistential:
case Node::Kind::ProtocolList:
return false;
default:
Expand Down
3 changes: 3 additions & 0 deletions lldb/test/API/lang/swift/constrained_existential/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SWIFT_SOURCES := main.swift

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -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')
28 changes: 28 additions & 0 deletions lldb/test/API/lang/swift/constrained_existential/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
protocol P1<U> {
associatedtype U
func get1() -> U
}

protocol P2<V> {
associatedtype V
func get2() -> V
}

struct Impl : P1<Int>, P2<(Int, Int)> {
let i = 23
func get1() -> Int { return i }
func get2() -> (Int, Int) { return (4, 2) }
}

struct S<T> {
let s: any P1<T> & P2<(T, T)>
}

func f() {
let s0: any P1<Int> & P2<(Int, Int)> = Impl()
let s = S(s: Impl())
print("break here")
}

f()

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SWIFT_SOURCES := main.swift

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -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:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could create a bug report to track this, unless it's something you plan on fixing soon

# lldbutil.check_variable(self, var_s_s6, use_dynamic=True, summary="Int")

self.expect("expression -- s.s1", substrs=['1...1'])
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class C {}

struct S {
let l0 = 0
let s1 : any Sequence<Int> = 1...1
let l1 = 10
let s2 : any Sequence<Int> = 1...200
let l2 = 20
let s3 : (any Sequence<Int>)? = 1...2
let l3 = 30
let s4 : (any Sequence<Int>)? = 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()