[Deserialization] Require labels to match when looking for closely-matching clang declarations

This commit is contained in:
Doug Gregor
2025-11-02 08:32:50 -08:00
parent 38c23bcdda
commit 1bae4da121
3 changed files with 9 additions and 1 deletions

View File

@@ -372,6 +372,8 @@ enum class TypeMatchFlags {
IgnoreSendability = 1 << 7,
/// Ignore global actor isolation attributes on functions when matching types.
IgnoreFunctionGlobalActorIsolation = 1 << 8,
/// Require parameter labels to match.
RequireMatchingParameterLabels = 1 << 9,
};
using TypeMatchOptions = OptionSet<TypeMatchFlags>;

View File

@@ -3604,6 +3604,11 @@ static bool matches(CanType t1, CanType t2, TypeMatchOptions matchMode,
OptionalUnwrapping::None)) {
return false;
}
if (matchMode.contains(TypeMatchFlags::RequireMatchingParameterLabels)&&
fn1Params[i].getLabel() != fn2Params[i].getLabel()) {
return false;
}
}
// Results are covariant.

View File

@@ -2013,7 +2013,8 @@ namespace {
return TypeComparison::Equal;
if (nearMatchOk) {
TypeMatchOptions options = TypeMatchFlags::AllowTopLevelOptionalMismatch;
TypeMatchOptions options = TypeMatchFlags::RequireMatchingParameterLabels;
options |= TypeMatchFlags::AllowTopLevelOptionalMismatch;
options |= TypeMatchFlags::AllowNonOptionalForIUOParam;
options |= TypeMatchFlags::IgnoreNonEscapingForOptionalFunctionParam;
options |= TypeMatchFlags::IgnoreFunctionSendability;