File tree Expand file tree Collapse file tree 1 file changed +22
-32
lines changed Expand file tree Collapse file tree 1 file changed +22
-32
lines changed Original file line number Diff line number Diff line change 1
1
// RUN: %target-typecheck-verify-swift
2
2
3
-
4
- protocol P
5
- {
6
- subscript< Value> ( x: Value ) -> Int // expected-note {{protocol requires subscript with type '<Value> (Value) -> Int'; do you want to add a stub?}}
7
- {
8
- get
9
- }
3
+ protocol P {
4
+ subscript< Value> ( x: Value ) -> Int // expected-note {{protocol requires subscript with type '<Value> (Value) -> Int'; do you want to add a stub?}}
5
+ {
6
+ get
7
+ }
10
8
}
11
9
12
- struct S : P // expected-error {{type 'S' does not conform to protocol 'P'}}
10
+ struct S : P // expected-error {{type 'S' does not conform to protocol 'P'}}
13
11
{
14
- subscript< Value> ( x: Int ) -> Value // expected-note {{candidate has non-matching type '<Value> (Int) -> Value'}}
15
- {
16
- } // expected-error {{missing return in subscript expected to return 'Value'}}
12
+ subscript< Value> ( x: Int ) -> Value // expected-note {{candidate has non-matching type '<Value> (Int) -> Value'}}
13
+ {
14
+ } // expected-error {{missing return in subscript expected to return 'Value'}}
17
15
}
18
16
19
-
20
-
21
- struct S2 : P
22
- {
23
- subscript< Value> ( x: Value ) -> Int
24
- {
25
- return 123 ;
26
- }
17
+ struct S2 : P {
18
+ subscript< Value> ( x: Value ) -> Int {
19
+ return 123
20
+ }
27
21
}
28
22
29
- protocol P2
30
- {
31
- subscript( x: Int ) -> Int
32
- {
33
- get
34
- }
23
+ protocol P2 {
24
+ subscript( x: Int ) -> Int
25
+ {
26
+ get
27
+ }
35
28
}
36
29
37
- struct S3 : P2
38
- {
39
- subscript( x: Int ) -> Int
40
- {
41
- return x;
42
- }
30
+ struct S3 : P2 {
31
+ subscript( x: Int ) -> Int {
32
+ return x
33
+ }
43
34
}
44
-
You can’t perform that action at this time.
0 commit comments