File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -2204,9 +2204,24 @@ static void initGenericClassObjCName(ClassMetadata *theClass) {
2204
2204
2205
2205
auto string = Demangle::mangleNodeOld (globalNode);
2206
2206
2207
- auto fullNameBuf = (char *)swift_slowAlloc (string.size () + 1 , 0 );
2207
+ // If the class is in the Swift module, add a $ to the end of the ObjC
2208
+ // name. The old and new Swift libraries must be able to coexist in
2209
+ // the same process, and this avoids warnings due to the ObjC names
2210
+ // colliding.
2211
+ bool addSuffix = strncmp (string.c_str (), " _TtGCs" , 6 ) == 0 ;
2212
+
2213
+ size_t allocationSize = string.size () + 1 ;
2214
+ if (addSuffix)
2215
+ allocationSize += 1 ;
2216
+
2217
+ auto fullNameBuf = (char *)swift_slowAlloc (allocationSize, 0 );
2208
2218
memcpy (fullNameBuf, string.c_str (), string.size () + 1 );
2209
2219
2220
+ if (addSuffix) {
2221
+ fullNameBuf[string.size ()] = ' $' ;
2222
+ fullNameBuf[string.size () + 1 ] = ' \0 ' ;
2223
+ }
2224
+
2210
2225
auto theMetaclass = (ClassMetadata *)object_getClass ((id)theClass);
2211
2226
2212
2227
getROData (theClass)->Name = fullNameBuf;
You can’t perform that action at this time.
0 commit comments