@@ -3840,6 +3840,8 @@ ManglingErrorOr<NodePointer> Demangle::getUnspecialized(Node *node,
38403840 case Node::Kind::TypeAlias:
38413841 case Node::Kind::OtherNominalType: {
38423842 NodePointer result = Factory.createNode (node->getKind ());
3843+
3844+ DEMANGLER_ASSERT (node->hasChildren (), node);
38433845 NodePointer parentOrModule = node->getChild (0 );
38443846 if (isSpecialized (parentOrModule)) {
38453847 auto unspec = getUnspecialized (parentOrModule, Factory);
@@ -3860,21 +3862,25 @@ ManglingErrorOr<NodePointer> Demangle::getUnspecialized(Node *node,
38603862 case Node::Kind::BoundGenericProtocol:
38613863 case Node::Kind::BoundGenericOtherNominalType:
38623864 case Node::Kind::BoundGenericTypeAlias: {
3865+ DEMANGLER_ASSERT (node->hasChildren (), node);
38633866 NodePointer unboundType = node->getChild (0 );
38643867 DEMANGLER_ASSERT (unboundType->getKind () == Node::Kind::Type, unboundType);
3868+ DEMANGLER_ASSERT (unboundType->hasChildren (), unboundType);
38653869 NodePointer nominalType = unboundType->getChild (0 );
38663870 if (isSpecialized (nominalType))
38673871 return getUnspecialized (nominalType, Factory);
38683872 return nominalType;
38693873 }
38703874
38713875 case Node::Kind::ConstrainedExistential: {
3876+ DEMANGLER_ASSERT (node->hasChildren (), node);
38723877 NodePointer unboundType = node->getChild (0 );
38733878 DEMANGLER_ASSERT (unboundType->getKind () == Node::Kind::Type, unboundType);
38743879 return unboundType;
38753880 }
38763881
38773882 case Node::Kind::BoundGenericFunction: {
3883+ DEMANGLER_ASSERT (node->hasChildren (), node);
38783884 NodePointer unboundFunction = node->getChild (0 );
38793885 DEMANGLER_ASSERT (unboundFunction->getKind () == Node::Kind::Function ||
38803886 unboundFunction->getKind () ==
@@ -3886,6 +3892,7 @@ ManglingErrorOr<NodePointer> Demangle::getUnspecialized(Node *node,
38863892 }
38873893
38883894 case Node::Kind::Extension: {
3895+ DEMANGLER_ASSERT (node->getNumChildren () >= 2 , node);
38893896 NodePointer parent = node->getChild (1 );
38903897 if (!isSpecialized (parent))
38913898 return node;
0 commit comments