Skip to content

Commit 1bae4da

Browse files
committed
[Deserialization] Require labels to match when looking for closely-matching clang declarations
1 parent 38c23bc commit 1bae4da

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

include/swift/AST/Types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ enum class TypeMatchFlags {
372372
IgnoreSendability = 1 << 7,
373373
/// Ignore global actor isolation attributes on functions when matching types.
374374
IgnoreFunctionGlobalActorIsolation = 1 << 8,
375+
/// Require parameter labels to match.
376+
RequireMatchingParameterLabels = 1 << 9,
375377
};
376378
using TypeMatchOptions = OptionSet<TypeMatchFlags>;
377379

lib/AST/Type.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3604,6 +3604,11 @@ static bool matches(CanType t1, CanType t2, TypeMatchOptions matchMode,
36043604
OptionalUnwrapping::None)) {
36053605
return false;
36063606
}
3607+
3608+
if (matchMode.contains(TypeMatchFlags::RequireMatchingParameterLabels)&&
3609+
fn1Params[i].getLabel() != fn2Params[i].getLabel()) {
3610+
return false;
3611+
}
36073612
}
36083613

36093614
// Results are covariant.

lib/Serialization/Deserialization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,8 @@ namespace {
20132013
return TypeComparison::Equal;
20142014

20152015
if (nearMatchOk) {
2016-
TypeMatchOptions options = TypeMatchFlags::AllowTopLevelOptionalMismatch;
2016+
TypeMatchOptions options = TypeMatchFlags::RequireMatchingParameterLabels;
2017+
options |= TypeMatchFlags::AllowTopLevelOptionalMismatch;
20172018
options |= TypeMatchFlags::AllowNonOptionalForIUOParam;
20182019
options |= TypeMatchFlags::IgnoreNonEscapingForOptionalFunctionParam;
20192020
options |= TypeMatchFlags::IgnoreFunctionSendability;

0 commit comments

Comments
 (0)