Merge pull request #39188 from amritpan/projected-value-labels

[CSSimplify] Fix a bug where the omitted projected value label was missing as an acceptable parameter label for property wrappers
This commit is contained in:
Holly Borla
2021-09-28 16:57:28 -07:00
committed by GitHub
3 changed files with 34 additions and 17 deletions

View File

@@ -282,22 +282,19 @@ static bool matchCallArgumentsImpl(
// requiring further checking at the end.
bool potentiallyOutOfOrder = false;
// Local function that claims the argument at \c argNumber, returning the
// Local function that claims the argument at \c argIdx, returning the
// index of the claimed argument. This is primarily a helper for
// \c claimNextNamed.
auto claim = [&](Identifier expectedName, unsigned argNumber,
auto claim = [&](Identifier expectedName, unsigned argIdx,
bool ignoreNameClash = false) -> unsigned {
// Make sure we can claim this argument.
assert(argNumber != numArgs && "Must have a valid index to claim");
assert(!claimedArgs[argNumber] && "Argument already claimed");
assert(argIdx != numArgs && "Must have a valid index to claim");
assert(!claimedArgs[argIdx] && "Argument already claimed");
auto argLabel = args[argNumber].getLabel();
if (!actualArgNames.empty()) {
// We're recording argument names; record this one.
actualArgNames[argNumber] = expectedName;
} else if (argLabel != expectedName && !ignoreNameClash &&
!(argLabel.str().startswith("$") &&
argLabel.str().drop_front() == expectedName.str())) {
actualArgNames[argIdx] = expectedName;
} else if (!ignoreNameClash && !args[argIdx].matchParameterLabel(expectedName)) {
// We have an argument name mismatch. Start recording argument names.
actualArgNames.resize(numArgs);
@@ -313,12 +310,12 @@ static bool matchCallArgumentsImpl(
}
// Record this argument name.
actualArgNames[argNumber] = expectedName;
actualArgNames[argIdx] = expectedName;
}
claimedArgs[argNumber] = true;
claimedArgs[argIdx] = true;
++numClaimedArgs;
return argNumber;
return argIdx;
};
// Local function that skips over any claimed arguments.
@@ -343,11 +340,8 @@ static bool matchCallArgumentsImpl(
// Go hunting for an unclaimed argument whose name does match.
Optional<unsigned> claimedWithSameName;
for (unsigned i = nextArgIdx; i != numArgs; ++i) {
auto argLabel = args[i].getLabel();
if (argLabel != paramLabel &&
!(argLabel.str().startswith("$") &&
argLabel.str().drop_front() == paramLabel.str())) {
if (!args[i].matchParameterLabel(paramLabel)) {
// If this is an attempt to claim additional unlabeled arguments
// for variadic parameter, we have to stop at first labeled argument.
if (forVariadic)
@@ -379,7 +373,7 @@ static bool matchCallArgumentsImpl(
// func foo(_ a: Int, _ b: Int = 0, c: Int = 0, _ d: Int) {}
// foo(1, c: 2, 3) // -> `3` will be claimed as '_ b:'.
// ```
if (argLabel.empty())
if (args[i].getLabel().empty())
continue;
potentiallyOutOfOrder = true;