@@ -71,17 +71,18 @@ namespace {
71
71
};
72
72
}
73
73
74
- static Identifier getNameForObjC (const NominalTypeDecl *NTD ,
74
+ static Identifier getNameForObjC (const ValueDecl *VD ,
75
75
CustomNamesOnly_t customNamesOnly = Normal) {
76
- assert (isa<ClassDecl>(NTD) || isa<ProtocolDecl>(NTD) || isa<EnumDecl>(NTD));
77
- if (auto objc = NTD->getAttrs ().getAttribute <ObjCAttr>()) {
76
+ assert (isa<ClassDecl>(VD) || isa<ProtocolDecl>(VD)
77
+ || isa<EnumDecl>(VD) || isa<EnumElementDecl>(VD));
78
+ if (auto objc = VD->getAttrs ().getAttribute <ObjCAttr>()) {
78
79
if (auto name = objc->getName ()) {
79
80
assert (name->getNumSelectorPieces () == 1 );
80
81
return name->getSelectorPieces ().front ();
81
82
}
82
83
}
83
84
84
- return customNamesOnly ? Identifier () : NTD ->getName ();
85
+ return customNamesOnly ? Identifier () : VD ->getName ();
85
86
}
86
87
87
88
@@ -255,12 +256,18 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
255
256
// Print the cases as the concatenation of the enum name with the case
256
257
// name.
257
258
os << " " ;
258
- if (customName.empty ()) {
259
- os << ED->getName ();
259
+ Identifier customEltName = getNameForObjC (Elt, CustomNamesOnly);
260
+ if (customEltName.empty ()) {
261
+ if (customName.empty ()) {
262
+ os << ED->getName ();
263
+ } else {
264
+ os << customName;
265
+ }
266
+ os << Elt->getName ();
260
267
} else {
261
- os << customName;
268
+ os << customEltName
269
+ << " SWIFT_COMPILE_NAME(\" " << Elt->getName () << " \" )" ;
262
270
}
263
- os << Elt->getName ();
264
271
265
272
if (auto ILE = cast_or_null<IntegerLiteralExpr>(Elt->getRawValueExpr ())) {
266
273
os << " = " ;
0 commit comments