File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -377,8 +377,11 @@ class CodeCompletionResultBuilder {
377
377
// If the parameter is of the type @autoclosure ()->output, then the
378
378
// code completion should show the parameter of the output type
379
379
// instead of the function type ()->output.
380
- if (isAutoClosure)
381
- Ty = Ty->castTo <FunctionType>()->getResult ();
380
+ if (isAutoClosure) {
381
+ // 'Ty' may be ErrorType.
382
+ if (auto funcTy = Ty->getAs <FunctionType>())
383
+ Ty = funcTy->getResult ();
384
+ }
382
385
383
386
PrintOptions PO;
384
387
PO.SkipAttributes = true ;
Original file line number Diff line number Diff line change 92
92
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_ARRAY_2_SKIPPED | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_SKIPPED
93
93
94
94
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ARCHETYPE_GENERIC_1 | %FileCheck %s -check-prefix=ARCHETYPE_GENERIC_1
95
+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PARAM_WITH_ERROR_AUTOCLOSURE| %FileCheck %s -check-prefix=PARAM_WITH_ERROR_AUTOCLOSURE
95
96
96
97
var i1 = 1
97
98
var i2 = 2
@@ -738,3 +739,15 @@ func testGenricMethodOnGenericOfArchetype<Wrapped>(value: Wrap<Wrapped>) {
738
739
// ARCHETYPE_GENERIC_1: Begin completions
739
740
// ARCHETYPE_GENERIC_1: Decl[InstanceMethod]/CurrNominal: ['(']{#(fn): (Wrapped) -> _##(Wrapped) -> _#}[')'][#Wrap<_>#];
740
741
}
742
+
743
+ struct TestHasErrorAutoclosureParam {
744
+ func hasErrorAutoclosureParam( value: @autoclosure ( ) -> Value ) {
745
+ fatalError ( )
746
+ }
747
+ func test( ) {
748
+ hasErrorAutoclosureParam( #^PARAM_WITH_ERROR_AUTOCLOSURE^#
749
+ // PARAM_WITH_ERROR_AUTOCLOSURE: Begin completions, 1 items
750
+ // PARAM_WITH_ERROR_AUTOCLOSURE: Decl[InstanceMethod]/CurrNominal: ['(']{#value: <<error type>>#}[')'][#Void#];
751
+ // PARAM_WITH_ERROR_AUTOCLOSURE: End completions
752
+ }
753
+ }
You can’t perform that action at this time.
0 commit comments