@@ -1990,37 +1990,59 @@ bool TypeSystemSwiftTypeRef::IsPossibleDynamicType(opaque_compiler_type_t type,
1990
1990
auto impl = [&]() {
1991
1991
using namespace swift ::Demangle;
1992
1992
Demangler dem;
1993
- auto *node = DemangleCanonicalType (dem, type);
1994
- if (!node)
1995
- return false ;
1993
+ std::function<bool (NodePointer)> is_possible_dynamic =
1994
+ [&](NodePointer node) -> bool {
1995
+ if (!node)
1996
+ return false ;
1996
1997
1997
- if (node->getKind () == Node::Kind::TypeAlias) {
1998
- auto resolved = ResolveTypeAlias (this , GetSwiftASTContext (), dem, node);
1999
- if (auto *n = std::get<swift::Demangle::NodePointer>(resolved))
2000
- node = n;
2001
- }
1998
+ if (node->getKind () == Node::Kind::TypeAlias) {
1999
+ auto resolved = ResolveTypeAlias (this , GetSwiftASTContext (), dem, node);
2000
+ if (auto *n = std::get<swift::Demangle::NodePointer>(resolved))
2001
+ node = n;
2002
+ }
2002
2003
2003
- switch (node->getKind ()) {
2004
- case Node::Kind::Class:
2005
- case Node::Kind::BoundGenericClass:
2006
- case Node::Kind::Protocol:
2007
- case Node::Kind::ProtocolList:
2008
- case Node::Kind::ProtocolListWithClass:
2009
- case Node::Kind::ProtocolListWithAnyObject:
2010
- case Node::Kind::ExistentialMetatype:
2011
- case Node::Kind::DynamicSelf:
2012
- return true ;
2013
- case Node::Kind::BuiltinTypeName: {
2014
- if (!node->hasText ())
2004
+ switch (node->getKind ()) {
2005
+ case Node::Kind::Class:
2006
+ case Node::Kind::BoundGenericClass:
2007
+ case Node::Kind::Protocol:
2008
+ case Node::Kind::ProtocolList:
2009
+ case Node::Kind::ProtocolListWithClass:
2010
+ case Node::Kind::ProtocolListWithAnyObject:
2011
+ case Node::Kind::ExistentialMetatype:
2012
+ case Node::Kind::DynamicSelf:
2013
+ return true ;
2014
+ case Node::Kind::BoundGenericStructure:
2015
+ case Node::Kind::BoundGenericEnum: {
2016
+ if (node->getNumChildren () < 2 )
2017
+ return false ;
2018
+ NodePointer type_list = node->getLastChild ();
2019
+ if (type_list->getKind () != Node::Kind::TypeList)
2020
+ return false ;
2021
+ for (size_t i = 0 ; i < type_list->getNumChildren (); ++i) {
2022
+ NodePointer child = type_list->getChild (i);
2023
+ if (child->getKind () == Node::Kind::Type) {
2024
+ child = child->getFirstChild ();
2025
+ if (is_possible_dynamic (child))
2026
+ return true ;
2027
+ }
2028
+ }
2015
2029
return false ;
2016
- StringRef name = node->getText ();
2017
- return name == swift::BUILTIN_TYPE_NAME_RAWPOINTER ||
2018
- name == swift::BUILTIN_TYPE_NAME_NATIVEOBJECT ||
2019
- name == swift::BUILTIN_TYPE_NAME_BRIDGEOBJECT;
2020
- }
2021
- default :
2022
- return ContainsGenericTypeParameter (node);
2023
- }
2030
+ }
2031
+ case Node::Kind::BuiltinTypeName: {
2032
+ if (!node->hasText ())
2033
+ return false ;
2034
+ StringRef name = node->getText ();
2035
+ return name == swift::BUILTIN_TYPE_NAME_RAWPOINTER ||
2036
+ name == swift::BUILTIN_TYPE_NAME_NATIVEOBJECT ||
2037
+ name == swift::BUILTIN_TYPE_NAME_BRIDGEOBJECT;
2038
+ }
2039
+ default :
2040
+ return ContainsGenericTypeParameter (node);
2041
+ }
2042
+ };
2043
+
2044
+ auto *node = DemangleCanonicalType (dem, type);
2045
+ return is_possible_dynamic (node);
2024
2046
};
2025
2047
VALIDATE_AND_RETURN (
2026
2048
impl, IsPossibleDynamicType, type,
0 commit comments