File tree Expand file tree Collapse file tree 2 files changed +47
-3
lines changed Expand file tree Collapse file tree 2 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -2575,9 +2575,9 @@ static bool fixItOverrideDeclarationTypesImpl(
2575
2575
});
2576
2576
}
2577
2577
2578
- auto resultType = subscript-> getDeclContext ()-> mapTypeIntoContext (
2579
- subscript->getElementInterfaceType ());
2580
- auto baseResultType = baseSubscript->getDeclContext ()-> mapTypeIntoContext (
2578
+ auto resultType =
2579
+ subscript->mapTypeIntoContext (subscript-> getElementInterfaceType ());
2580
+ auto baseResultType = baseSubscript->mapTypeIntoContext (
2581
2581
baseSubscript->getElementInterfaceType ());
2582
2582
fixedAny |= checkType (resultType, ParamDecl::Specifier::Default,
2583
2583
baseResultType, ParamDecl::Specifier::Default,
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
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
+ }
10
+ }
11
+
12
+ struct S : P // expected-error {{type 'S' does not conform to protocol 'P'}}
13
+ {
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'}}
17
+ }
18
+
19
+
20
+
21
+ struct S2 : P
22
+ {
23
+ subscript< Value> ( x: Value ) -> Int
24
+ {
25
+ return 123 ;
26
+ }
27
+ }
28
+
29
+ protocol P2
30
+ {
31
+ subscript( x: Int ) -> Int
32
+ {
33
+ get
34
+ }
35
+ }
36
+
37
+ struct S3 : P2
38
+ {
39
+ subscript( x: Int ) -> Int
40
+ {
41
+ return x;
42
+ }
43
+ }
44
+
You can’t perform that action at this time.
0 commit comments