Skip to content

Commit ab2adb8

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[typechecker] allow matching enums to functions as well, not just functions to enums
1 parent c75c227 commit ab2adb8

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/AST/Decl.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,17 +2090,20 @@ bool swift::conflicting(ASTContext &ctx,
20902090
if (!conflicting(sig1, sig2, skipProtocolExtensionCheck))
20912091
return false;
20922092

2093-
// Two enum elements always conflict with each other. At this point, they
2093+
// Functions and enum elements do not conflict with each other if their types
2094+
// are different.
2095+
if ((sig1.IsFunction == sig2.IsEnumElement ||
2096+
sig1.IsEnumElement == sig2.IsFunction) &&
2097+
sig1Type != sig2Type) {
2098+
return false;
2099+
}
2100+
2101+
// Enum elements always conflict with each other. At this point, they
20942102
// have the same base name but different types.
20952103
if (sig1.IsEnumElement == sig2.IsEnumElement) {
20962104
return true;
20972105
}
20982106

2099-
// A function does not conflict with an enum element if their types differ.
2100-
if (sig1.IsFunction == sig2.IsEnumElement && sig1Type != sig2Type) {
2101-
return false;
2102-
}
2103-
21042107
// Functions always conflict with non-functions with the same signature.
21052108
// In practice, this only applies for zero argument functions.
21062109
if (sig1.IsFunction != sig2.IsFunction)

0 commit comments

Comments
 (0)