Skip to content

Commit 91b41fc

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[typechecker] fix the check for two enums
1 parent ab2adb8 commit 91b41fc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/AST/Decl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,15 +2092,15 @@ bool swift::conflicting(ASTContext &ctx,
20922092

20932093
// Functions and enum elements do not conflict with each other if their types
20942094
// are different.
2095-
if ((sig1.IsFunction == sig2.IsEnumElement ||
2096-
sig1.IsEnumElement == sig2.IsFunction) &&
2095+
if (((sig1.IsFunction && sig2.IsEnumElement) ||
2096+
(sig1.IsEnumElement && sig2.IsFunction)) &&
20972097
sig1Type != sig2Type) {
20982098
return false;
20992099
}
21002100

21012101
// Enum elements always conflict with each other. At this point, they
21022102
// have the same base name but different types.
2103-
if (sig1.IsEnumElement == sig2.IsEnumElement) {
2103+
if (sig1.IsEnumElement && sig2.IsEnumElement) {
21042104
return true;
21052105
}
21062106

test/decl/overload.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,15 +495,15 @@ enum SR_10084_E {
495495
}
496496

497497
enum SR_10084_E_1 {
498-
static func foo(_ name: String) -> SR_10084_E_1 { // expected-note {{'foo' previously declared here}}
498+
static func foo(_ name: String) -> SR_10084_E_1 {
499499
return .foo(SR_10084_S(name: name))
500500
}
501501

502-
static func foo(_ value: SR_10084_S) -> SR_10084_E_1 { // expected-error {{invalid redeclaration of 'foo'}}
502+
static func foo(_ value: SR_10084_S) -> SR_10084_E_1 { // expected-note {{'foo' previously declared here}}
503503
return .foo(value)
504504
}
505505

506-
case foo(SR_10084_S)
506+
case foo(SR_10084_S) // expected-error {{invalid redeclaration of 'foo'}}
507507
}
508508

509509
enum SR_10084_E_2 {

0 commit comments

Comments
 (0)