Skip to content

Commit 41e31e4

Browse files
[tests] Add regression diagnostics tests for SR-14408
1 parent b5dbb69 commit 41e31e4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/Constraints/enum_cases.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,28 @@ struct EnumElementPatternFromContextualType<T> {
171171
}
172172
}
173173
}
174+
175+
// SR-14408
176+
enum CompassPoint {
177+
case North(Int)
178+
case South
179+
case East
180+
case West
181+
}
182+
183+
func isNorth(c : CompassPoint) -> Bool {
184+
// expected-error@+1{{member 'North' expects argument of type 'Int'}}
185+
return c == .North // expected-error {{binary operator '==' cannot be applied to two 'CompassPoint' operands}}
186+
// expected-note@-1 {{binary operator '==' cannot be synthesized for enums with associated values}}
187+
}
188+
189+
func isNorth2(c : CompassPoint) -> Bool {
190+
// expected-error@+1{{member 'North' expects argument of type 'Int'}}
191+
return .North == c // expected-error {{binary operator '==' cannot be applied to two 'CompassPoint' operands}}
192+
// expected-note@-1 {{binary operator '==' cannot be synthesized for enums with associated values}}
193+
}
194+
195+
func isSouth(c : CompassPoint) -> Bool {
196+
return c == .South // expected-error {{binary operator '==' cannot be applied to two 'CompassPoint' operands}}
197+
// expected-note@-1 {{binary operator '==' cannot be synthesized for enums with associated values}}
198+
}

0 commit comments

Comments
 (0)