@@ -1575,22 +1575,47 @@ swift::Demangle::NodePointer TypeSystemSwiftTypeRef::GetDemangleTreeForPrinting(
15751575 return GetNodeForPrintingImpl (dem, node, flavor, resolve_objc_module);
15761576}
15771577
1578- // / Determine wether this demangle tree contains a node of kind \c kind.
1578+ // / Determine wether this demangle tree contains a node of kind \c kind and with
1579+ // / text \c text (if provided).
15791580static bool Contains (swift::Demangle::NodePointer node,
1580- swift::Demangle::Node::Kind kind) {
1581+ swift::Demangle::Node::Kind kind,
1582+ llvm::StringRef text = " " ) {
15811583 if (!node)
15821584 return false ;
15831585
1584- if (node->getKind () == kind)
1585- return true ;
1586+ if (node->getKind () == kind) {
1587+ if (text.empty ())
1588+ return true ;
1589+ if (!node->hasText ())
1590+ return false ;
1591+ return node->getText () == text;
1592+ }
15861593
15871594 for (swift::Demangle::NodePointer child : *node)
1588- if (Contains (child, kind))
1595+ if (Contains (child, kind, text ))
15891596 return true ;
15901597
15911598 return false ;
15921599}
15931600
1601+ static bool ProtocolCompositionContainsSingleObjcProtocol (
1602+ swift::Demangle::NodePointer node) {
1603+ // Kind=ProtocolList
1604+ // Kind=TypeList
1605+ // Kind=Type
1606+ // Kind=Protocol
1607+ // Kind=Module, text="__C"
1608+ // Kind=Identifier, text="SomeIdentifier"
1609+ if (node->getKind () != Node::Kind::ProtocolList)
1610+ return false ;
1611+ NodePointer type_list = node->getFirstChild ();
1612+ if (type_list->getKind () != Node::Kind::TypeList ||
1613+ type_list->getNumChildren () != 1 )
1614+ return false ;
1615+ NodePointer type = type_list->getFirstChild ();
1616+ return Contains (type, Node::Kind::Module, swift::MANGLING_MODULE_OBJC);
1617+ }
1618+
15941619// / Determine wether this demangle tree contains a generic type parameter.
15951620static bool ContainsGenericTypeParameter (swift::Demangle::NodePointer node) {
15961621 return Contains (node, swift::Demangle::Node::Kind::DependentGenericParamType);
@@ -1777,6 +1802,8 @@ uint32_t TypeSystemSwiftTypeRef::CollectTypeInfo(
17771802 swift_flags |= eTypeIsProtocol;
17781803 // Bug-for-bug-compatibility.
17791804 swift_flags |= eTypeHasChildren | eTypeIsStructUnion;
1805+ if (ProtocolCompositionContainsSingleObjcProtocol (node))
1806+ swift_flags |= eTypeIsObjC | eTypeHasValue;
17801807 break ;
17811808
17821809 case Node::Kind::ExistentialMetatype:
0 commit comments