Skip to content

Commit 3fb56bc

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[test] add more tests
1 parent d0f9b7c commit 3fb56bc

File tree

1 file changed

+61
-3
lines changed

1 file changed

+61
-3
lines changed

test/decl/overload.swift

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,21 @@ struct SR_10084_S {
485485
enum SR_10084_E {
486486
case foo(SR_10084_S) // expected-note {{'foo' previously declared here}}
487487

488-
static func foo(_ name: String) -> SR_10084_E { // Ok
488+
static func foo(_ name: String) -> SR_10084_E { // Okay
489489
return .foo(SR_10084_S(name: name))
490490
}
491491

492+
func foo(_ name: Bool) -> SR_10084_E { // Okay
493+
return .foo(SR_10084_S(name: "Test"))
494+
}
495+
492496
static func foo(_ value: SR_10084_S) -> SR_10084_E { // expected-error {{invalid redeclaration of 'foo'}}
493497
return .foo(value)
494498
}
495499
}
496500

497501
enum SR_10084_E_1 {
498-
static func foo(_ name: String) -> SR_10084_E_1 {
502+
static func foo(_ name: String) -> SR_10084_E_1 { // Okay
499503
return .foo(SR_10084_S(name: name))
500504
}
501505

@@ -513,7 +517,61 @@ enum SR_10084_E_2 {
513517
fatalError()
514518
}
515519

516-
static func fn(_ x: @escaping () -> Int) -> SR_10084_E_2 { // Ok
520+
static func fn(_ x: @escaping () -> Int) -> SR_10084_E_2 { // Okay
517521
fatalError()
518522
}
523+
524+
static func fn(_ x: @escaping () -> Bool) -> SR_10084_E_2 { // Okay
525+
fatalError()
526+
}
527+
}
528+
529+
enum SR_10084_E_3 {
530+
protocol A {} //expected-error {{protocol 'A' cannot be nested inside another declaration}} // expected-note {{'A' previously declared here}}
531+
case A // expected-error {{invalid redeclaration of 'A'}}
532+
}
533+
534+
enum SR_10084_E_4 {
535+
class B {} // expected-note {{'B' previously declared here}}
536+
case B // expected-error {{invalid redeclaration of 'B'}}
537+
}
538+
539+
enum SR_10084_E_5 {
540+
struct C {} // expected-note {{'C' previously declared here}}
541+
case C // expected-error {{invalid redeclaration of 'C'}}
542+
}
543+
544+
enum SR_10084_E_6 {
545+
case D // expected-note {{'D' previously declared here}}
546+
protocol D {} //expected-error {{protocol 'D' cannot be nested inside another declaration}} // expected-error {{invalid redeclaration of 'D'}}
547+
}
548+
549+
enum SR_10084_E_7 {
550+
case E // expected-note {{'E' previously declared here}}
551+
class E {} // expected-error {{invalid redeclaration of 'E'}}
552+
}
553+
554+
enum SR_10084_E_8 {
555+
case F // expected-note {{'F' previously declared here}}
556+
struct F {} // expected-error {{invalid redeclaration of 'F'}}
557+
}
558+
559+
enum SR_10084_E_9 {
560+
case A // expected-note {{found this candidate}} // expected-note {{'A' previously declared here}}
561+
static let A: SR_10084_E_9 = .A // expected-note {{found this candidate}} // expected-error {{invalid redeclaration of 'A'}} // expected-error {{ambiguous use of 'A'}}
562+
}
563+
564+
enum SR_10084_E_10 {
565+
static let A: SR_10084_E_10 = .A // expected-note {{found this candidate}} // expected-note {{'A' previously declared here}} // expected-error {{ambiguous use of 'A'}}
566+
case A // expected-note {{found this candidate}} // expected-error {{invalid redeclaration of 'A'}}
567+
}
568+
569+
enum SR_10084_E_11 {
570+
case A // expected-note {{found this candidate}} // expected-note {{'A' previously declared here}}
571+
static let A: SR_10084_E_11 = .A // expected-note {{found this candidate}} // expected-error {{invalid redeclaration of 'A'}} // expected-error {{ambiguous use of 'A'}}
572+
}
573+
574+
enum SR_10084_E_12 {
575+
static let A: SR_10084_E_12 = .A // expected-note {{found this candidate}} // expected-note {{'A' previously declared here}} // expected-error {{ambiguous use of 'A'}}
576+
case A // expected-note {{found this candidate}} // expected-error {{invalid redeclaration of 'A'}}
519577
}

0 commit comments

Comments
 (0)