File tree Expand file tree Collapse file tree 3 files changed +45
-9
lines changed Expand file tree Collapse file tree 3 files changed +45
-9
lines changed Original file line number Diff line number Diff line change @@ -129,22 +129,20 @@ void ConformingMethodListCallbacks::getMatchingMethods(
129
129
// / Returns true if \p VD is a instance method whose return type conforms
130
130
// / to the requested protocols.
131
131
bool isMatchingMethod (ValueDecl *VD) {
132
- if (!isa<FuncDecl>(VD))
132
+ auto *FD = dyn_cast<FuncDecl>(VD);
133
+ if (!FD)
133
134
return false ;
134
- if (VD ->isStatic () || VD ->isOperator ())
135
+ if (FD ->isStatic () || FD ->isOperator ())
135
136
return false ;
136
137
137
- auto declTy = T->getTypeOfMember (CurModule, VD);
138
- if (declTy->is <ErrorType>())
138
+ auto resultTy = T->getTypeOfMember (CurModule, FD,
139
+ FD->getResultInterfaceType ());
140
+ if (resultTy->is <ErrorType>())
139
141
return false ;
140
142
141
- // Strip '(Self.Type) ->' and parameters.
142
- declTy = declTy->castTo <AnyFunctionType>()->getResult ();
143
- declTy = declTy->castTo <AnyFunctionType>()->getResult ();
144
-
145
143
// The return type conforms to any of the requested protocols.
146
144
for (auto Proto : ExpectedTypes) {
147
- if (CurModule->conformsToProtocol (declTy , Proto))
145
+ if (CurModule->conformsToProtocol (resultTy , Proto))
148
146
return true ;
149
147
}
150
148
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-ide-test -conforming-methods -source-filename %s -code-completion-token=CM1 -module-name MyModule -conforming-methods-expected-types '$s8MyModule6TargetPD' | %FileCheck %s -check-prefix=SI
2
+ // RUN: %target-swift-ide-test -conforming-methods -source-filename %s -code-completion-token=CM2 -module-name MyModule -conforming-methods-expected-types '$s8MyModule6TargetPD' | %FileCheck %s -check-prefix=SF
3
+
4
+ protocol Target { }
5
+ struct Concrete : Target { }
6
+
7
+ struct S < T> {
8
+ func returnsAnything< U> ( ) -> U { fatalError ( ) }
9
+ }
10
+
11
+ extension S where T == Int {
12
+ func returnsConcrete< U> ( _ x: U ) -> Concrete { fatalError ( ) }
13
+ }
14
+
15
+ func test( si: S < Int > , sf: S < Float > ) {
16
+ si. #^CM1^#
17
+ // SI: -----BEGIN CONFORMING METHOD LIST-----
18
+ // SI-NEXT: - TypeName: S<Int>
19
+ // SI-NEXT: - Members:
20
+ // SI-NEXT: - Name: returnsConcrete(_:)
21
+ // SI-NEXT: TypeName: Concrete
22
+ // SI-NEXT: -----END CONFORMING METHOD LIST-----
23
+
24
+ sf. #^CM2^#
25
+ // SF: -----BEGIN CONFORMING METHOD LIST-----
26
+ // SF-NEXT: - TypeName: S<Float>
27
+ // SF-NEXT: - Members: []
28
+ // SF-NEXT: -----END CONFORMING METHOD LIST-----
29
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-ide-test -conforming-methods -source-filename %s -code-completion-token=CC
2
+
3
+ protocol MyView { }
4
+
5
+ extension MyView {
6
+ func foo< Content> ( ) -> Content ? {
7
+ return nil#^CC^#
8
+ }
9
+ }
You can’t perform that action at this time.
0 commit comments