File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -5585,10 +5585,13 @@ void CodeCompletionCallbacksImpl::doneParsing() {
5585
5585
}
5586
5586
5587
5587
// KeyPath can be used as a function that receives its root type.
5588
- if (T->is <AnyFunctionType>() &&
5589
- T->castTo <AnyFunctionType>()->getNumParams () == 1 ) {
5590
- baseType = T->castTo <AnyFunctionType>()->getParams ()[0 ].getOldType ();
5591
- break ;
5588
+ if (T->is <AnyFunctionType>()) {
5589
+ auto *fnType = T->castTo <AnyFunctionType>();
5590
+ if (fnType->getNumParams () == 1 ) {
5591
+ const AnyFunctionType::Param ¶m = fnType->getParams ()[0 ];
5592
+ baseType = param.getParameterType ();
5593
+ break ;
5594
+ }
5592
5595
}
5593
5596
}
5594
5597
}
Original file line number Diff line number Diff line change 29
29
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONTEXT_FUNC_GENERICRESULT | %FileCheck %s -check-prefix=PERSONTYPE-DOT
30
30
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONTEXT_FUNC_ROOT | %FileCheck %s -check-prefix=PERSONTYPE-DOT
31
31
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONTEXT_FUNC_NONROOT | %FileCheck %s -check-prefix=OBJ-DOT
32
+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONTEXT_FUNC_INOUT | %FileCheck %s -check-prefix=PERSONTYPE-DOT
33
+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONTEXT_FUNC_VARIADIC | %FileCheck %s -check-prefix=ARRAYTYPE-DOT
32
34
33
35
class Person {
34
36
var name : String
@@ -163,10 +165,16 @@ func recvFuncGeneric<T>(_ fn: (Person) -> T) {
163
165
164
166
struct Wrap < T> {
165
167
func map< U> ( _ fn: ( T ) -> U ) -> U { fatalError ( ) }
168
+ func _inout< U> ( _ fn: ( inout T ) -> U ) -> U { fatalError ( ) }
169
+ func variadic< U> ( _ fn: ( T . . . ) -> U ) -> U { fatalError ( ) }
166
170
}
167
171
func testKeyPathAsFunctions( wrapped: Wrap < Person > ) {
168
172
let _ = wrapped. map ( \. #^CONTEXT_FUNC_ROOT^#)
169
173
// Same as TYPE_DOT.
170
174
let _ = wrapped. map ( \. friends [ 0 ] . #^CONTEXT_FUNC_NONROOT^#)
171
175
// Same as OBJ_DOT.
176
+ let _ = wrapped. _inout ( \. #^CONTEXT_FUNC_INOUT^#)
177
+ // Same as TYPE_DOT.
178
+ let _ = wrapped. variadic ( \. #^CONTEXT_FUNC_VARIADIC^#)
179
+ // Same as ARRAYTYPE_DOT.
172
180
}
You can’t perform that action at this time.
0 commit comments