@@ -1653,22 +1653,47 @@ swift::Demangle::NodePointer TypeSystemSwiftTypeRef::GetDemangleTreeForPrinting(
16531653 return GetNodeForPrintingImpl (dem, node, flavor, resolve_objc_module);
16541654}
16551655
1656- // / Determine wether this demangle tree contains a node of kind \c kind.
1656+ // / Determine wether this demangle tree contains a node of kind \c kind and with
1657+ // / text \c text (if provided).
16571658static bool Contains (swift::Demangle::NodePointer node,
1658- swift::Demangle::Node::Kind kind) {
1659+ swift::Demangle::Node::Kind kind,
1660+ llvm::StringRef text = " " ) {
16591661 if (!node)
16601662 return false ;
16611663
1662- if (node->getKind () == kind)
1663- return true ;
1664+ if (node->getKind () == kind) {
1665+ if (text.empty ())
1666+ return true ;
1667+ if (!node->hasText ())
1668+ return false ;
1669+ return node->getText () == text;
1670+ }
16641671
16651672 for (swift::Demangle::NodePointer child : *node)
1666- if (Contains (child, kind))
1673+ if (Contains (child, kind, text ))
16671674 return true ;
16681675
16691676 return false ;
16701677}
16711678
1679+ static bool ProtocolCompositionContainsSingleObjcProtocol (
1680+ swift::Demangle::NodePointer node) {
1681+ // Kind=ProtocolList
1682+ // Kind=TypeList
1683+ // Kind=Type
1684+ // Kind=Protocol
1685+ // Kind=Module, text="__C"
1686+ // Kind=Identifier, text="SomeIdentifier"
1687+ if (node->getKind () != Node::Kind::ProtocolList)
1688+ return false ;
1689+ NodePointer type_list = node->getFirstChild ();
1690+ if (type_list->getKind () != Node::Kind::TypeList ||
1691+ type_list->getNumChildren () != 1 )
1692+ return false ;
1693+ NodePointer type = type_list->getFirstChild ();
1694+ return Contains (type, Node::Kind::Module, swift::MANGLING_MODULE_OBJC);
1695+ }
1696+
16721697// / Determine wether this demangle tree contains a generic type parameter.
16731698static bool ContainsGenericTypeParameter (swift::Demangle::NodePointer node) {
16741699 return Contains (node, swift::Demangle::Node::Kind::DependentGenericParamType);
@@ -1855,6 +1880,8 @@ uint32_t TypeSystemSwiftTypeRef::CollectTypeInfo(
18551880 swift_flags |= eTypeIsProtocol;
18561881 // Bug-for-bug-compatibility.
18571882 swift_flags |= eTypeHasChildren | eTypeIsStructUnion;
1883+ if (ProtocolCompositionContainsSingleObjcProtocol (node))
1884+ swift_flags |= eTypeIsObjC | eTypeHasValue;
18581885 break ;
18591886
18601887 case Node::Kind::ExistentialMetatype:
0 commit comments