Skip to content

[lldb] Add TestBoundOpaqueArchetype test #5848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
2 changes: 1 addition & 1 deletion lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5240,7 +5240,6 @@ SwiftASTContext::GetTypeInfo(opaque_compiler_type_t type,
case swift::TypeKind::InOut:
case swift::TypeKind::Module:
case swift::TypeKind::ElementArchetype:
case swift::TypeKind::OpaqueTypeArchetype:
case swift::TypeKind::OpenedArchetype:
case swift::TypeKind::Pack:
case swift::TypeKind::PackExpansion:
Expand All @@ -5261,6 +5260,7 @@ SwiftASTContext::GetTypeInfo(opaque_compiler_type_t type,
assert(false && "Internal compiler type");
break;
case swift::TypeKind::UnboundGeneric:
case swift::TypeKind::OpaqueTypeArchetype:
break;

case swift::TypeKind::GenericFunction:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,7 @@ bool TypeSystemSwiftTypeRef::IsPossibleDynamicType(opaque_compiler_type_t type,
case Node::Kind::ProtocolListWithAnyObject:
case Node::Kind::ExistentialMetatype:
case Node::Kind::DynamicSelf:
case Node::Kind::OpaqueType:
return true;
case Node::Kind::BoundGenericStructure:
case Node::Kind::BoundGenericEnum: {
Expand Down
2 changes: 2 additions & 0 deletions lldb/test/API/lang/swift/bound_opaque_archetype/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SWIFT_SOURCES := main.swift
include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
import unittest2


class TestBoundOpaqueArchetype(TestBase):

@swiftTest
def test(self):
"""Tests that a type bound to an opaque archetype can be resolved correctly"""
self.build()
lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.swift"))
self.expect("v s", substrs=["S<", "opaque return type of", "f()"])
self.expect("po s", substrs=["S<C>"])

18 changes: 18 additions & 0 deletions lldb/test/API/lang/swift/bound_opaque_archetype/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
protocol P {}

class C: P {
}

struct S<T> {
let t: T
}
func f() -> some P {
let p: some P = C()
return p
}

let s = S(t: f())
print(s) // break here