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 @@ -2556,9 +2556,9 @@ static bool fixItOverrideDeclarationTypesImpl(
25562556 });
25572557 }
25582558
2559- auto resultType = subscript-> getDeclContext ()-> mapTypeIntoContext (
2560- subscript->getElementInterfaceType ());
2561- auto baseResultType = baseSubscript->getDeclContext ()-> mapTypeIntoContext (
2559+ auto resultType =
2560+ subscript->mapTypeIntoContext (subscript-> getElementInterfaceType ());
2561+ auto baseResultType = baseSubscript->mapTypeIntoContext (
25622562 baseSubscript->getElementInterfaceType ());
25632563 fixedAny |= checkType (resultType, ParamDecl::Specifier::Default,
25642564 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