Skip to content

Commit 3ee9c88

Browse files
committed
Demangler: fix de- and re-mangling of constrained extensions
SR-4512 rdar://problem/31471429
1 parent 7dd2828 commit 3ee9c88

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/Demangling/Demangler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,10 @@ NodePointer Demangler::demangleBoundGenericArgs(NodePointer Nominal,
905905
BoundParent = createWithChildren(Node::Kind::Extension,
906906
Context->getFirstChild(),
907907
BoundParent);
908+
if (Context->getNumChildren() == 3) {
909+
// Add the generic signature of the extension context.
910+
addChild(BoundParent, Context->getChild(2));
911+
}
908912
} else {
909913
BoundParent = demangleBoundGenericArgs(Context, TypeLists, TypeListIdx);
910914
}

lib/Demangling/Remangler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,10 @@ NodePointer Demangle::getUnspecialized(Node *node, NodeFactory &Factory) {
17841784
NodePointer result = Factory.createNode(Node::Kind::Extension);
17851785
result->addChild(node->getFirstChild(), Factory);
17861786
result->addChild(getUnspecialized(parent, Factory), Factory);
1787+
if (node->getNumChildren() == 3) {
1788+
// Add the generic signature of the extension.
1789+
result->addChild(node->getChild(2), Factory);
1790+
}
17871791
return result;
17881792
}
17891793
default:

test/Demangle/Inputs/manglings.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,5 @@ _SocketJoinOrLeaveMulticast ---> _SocketJoinOrLeaveMulticast
248248
_T0s10DictionaryV3t17E6Index2V1loiSbAEyxq__G_AGtFZ ---> static (extension in t17):Swift.Dictionary.Index2.< infix ((extension in t17):[A : B].Index2, (extension in t17):[A : B].Index2) -> Swift.Bool
249249
_T08mangling14varargsVsArrayySaySiG3arrd_SS1ntF ---> mangling.varargsVsArray (arr : Swift.Int..., n : Swift.String) -> ()
250250
_T08mangling14varargsVsArrayySaySiG3arrd_tF ---> mangling.varargsVsArray (arr : Swift.Int...) -> ()
251-
251+
_T0s13_UnicodeViewsVss22RandomAccessCollectionRzs0A8EncodingR_11SubSequence_5IndexQZAFRtzsAcERpzAE_AEQZAIRSs15UnsignedInteger8Iterator_7ElementRPzAE_AlMQZANRS13EncodedScalar_AlMQY_AORSr0_lE13CharacterViewVyxq__G ---> (extension in Swift):Swift._UnicodeViews<A, B><A, B where A: Swift.RandomAccessCollection, B: Swift.UnicodeEncoding, A.Index == A.SubSequence.Index, A.SubSequence: Swift.RandomAccessCollection, A.SubSequence == A.SubSequence.SubSequence, A.Iterator.Element: Swift.UnsignedInteger, A.Iterator.Element == A.SubSequence.Iterator.Element, A.SubSequence.Iterator.Element == B.EncodedScalar.Iterator.Element>.CharacterView
252+

0 commit comments

Comments
 (0)