mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Preserve default argument text through serialization (#18579)
This allows us to dump it in the generated interface, though it's still not syntax-highlighted. This is necessary for textual module interfaces, but it's also just a longstanding request for Xcode's "Generated Interface" / "Jump to Definition" feature. rdar://problem/18675831
This commit is contained in:
@@ -3168,6 +3168,12 @@ void Serializer::writeDecl(const Decl *D) {
|
||||
auto contextID = addDeclContextRef(param->getDeclContext());
|
||||
Type interfaceType = param->getInterfaceType();
|
||||
|
||||
// Only save the text for normal default arguments, not any of the special
|
||||
// ones.
|
||||
StringRef defaultArgumentText;
|
||||
if (param->getDefaultArgumentKind() == swift::DefaultArgumentKind::Normal)
|
||||
defaultArgumentText = param->getDefaultValueStringRepresentation();
|
||||
|
||||
unsigned abbrCode = DeclTypeAbbrCodes[ParamLayout::Code];
|
||||
ParamLayout::emitRecord(Out, ScratchRecord, abbrCode,
|
||||
addDeclBaseNameRef(param->getArgumentName()),
|
||||
@@ -3176,7 +3182,8 @@ void Serializer::writeDecl(const Decl *D) {
|
||||
getRawStableVarDeclSpecifier(param->getSpecifier()),
|
||||
addTypeRef(interfaceType),
|
||||
param->isVariadic(),
|
||||
getRawStableDefaultArgumentKind(param->getDefaultArgumentKind()));
|
||||
getRawStableDefaultArgumentKind(param->getDefaultArgumentKind()),
|
||||
defaultArgumentText);
|
||||
|
||||
if (interfaceType->hasError()) {
|
||||
param->getDeclContext()->dumpContext();
|
||||
|
||||
Reference in New Issue
Block a user