Merge pull request #70602 from ApolloZhu/macro/expression-as-default-argument

[Macros] Expression macro as caller-side default argument
This commit is contained in:
Doug Gregor
2024-02-14 16:10:11 -08:00
committed by GitHub
51 changed files with 730 additions and 25 deletions

View File

@@ -1415,6 +1415,7 @@ static uint8_t getRawStableDefaultArgumentKind(swift::DefaultArgumentKind kind)
CASE(EmptyArray)
CASE(EmptyDictionary)
CASE(StoredProperty)
CASE(ExpressionMacro)
#undef CASE
}
@@ -4402,12 +4403,14 @@ public:
swift::DefaultArgumentKind argKind = param->getDefaultArgumentKind();
if (argKind == swift::DefaultArgumentKind::Normal ||
argKind == swift::DefaultArgumentKind::StoredProperty) {
argKind == swift::DefaultArgumentKind::StoredProperty ||
argKind == swift::DefaultArgumentKind::ExpressionMacro) {
defaultArgumentText =
param->getDefaultValueStringRepresentation(scratch);
// Serialize the type of the default expression (if any).
defaultExprType = param->getTypeOfDefaultExpr();
if (!param->hasCallerSideDefaultExpr())
defaultExprType = param->getTypeOfDefaultExpr();
}
auto isolation = param->getInitializerIsolation();