Skip to content

Commit 37ffd6b

Browse files
committed
[Test] Add a test case for static subscript
1 parent eb045f5 commit 37ffd6b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

test/decl/protocol/req/witness_fix_its.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ protocol Foo {
1111
static postfix func ^^^^(value: Self) -> Int // expected-note {{protocol requires function '^^^^' with type '(ConformsToFoo) -> Int'; do you want to add a stub?}}
1212
func bar4(closure: () throws -> Int) rethrows // expected-note {{protocol requires function 'bar4(closure:)' with type '(() throws -> Int) throws -> ()'; do you want to add a stub?}}
1313
var bar5: Int { get set } // expected-note {{protocol requires property 'bar5' with type 'Int'; do you want to add a stub?}}
14+
static subscript(_ pos: Int) -> Int { get } // expected-note {{protocol requires subscript with type '(Int) -> Int'; do you want to add a stub?}}
1415
}
1516

1617
struct ConformsToFoo: Foo { // expected-error {{type 'ConformsToFoo' does not conform to protocol 'Foo'}}
@@ -23,4 +24,5 @@ struct ConformsToFoo: Foo { // expected-error {{type 'ConformsToFoo' does not co
2324
// expected-note@-1 {{candidate is prefix, not postfix as required}}{{10-16=postfix}}
2425
func bar4(closure: () throws -> Int) throws {} // expected-note {{candidate is not 'rethrows', but protocol requires it}}{{40-46=rethrows}}
2526
var bar5: Int { return 0 } // expected-note {{candidate is not settable, but protocol requires it}}{{none}}
27+
subscript(_ pos: Int) -> Int { return 0 } // expected-note {{candidate operates on an instance, not a type as required}}{{3-3=static}}
2628
}

0 commit comments

Comments
 (0)