File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -374,12 +374,15 @@ void ArgumentTypeCheckCompletionCallback::collectResults(
374
374
}
375
375
if (Result.FuncTy ) {
376
376
if (auto FuncTy = Result.FuncTy ) {
377
+ // Only show call pattern completions if the function isn't
378
+ // overridden.
377
379
if (ShadowedDecls.count (Result.FuncD ) == 0 ) {
378
- // Don't show call pattern completions if the function is
379
- // overridden.
380
380
if (Result.IsSubscript ) {
381
- assert (SemanticContext != SemanticContextKind::None);
381
+ // The subscript decl may not be preset for e.g the implicit
382
+ // `keyPath:` subscript. Such a subscript is allowed on any
383
+ // non-nominal type, so the semantic context may be none.
382
384
auto *SD = dyn_cast_or_null<SubscriptDecl>(Result.FuncD );
385
+ assert (!SD || SemanticContext != SemanticContextKind::None);
383
386
Lookup.addSubscriptCallPattern (FuncTy, SD, SemanticContext);
384
387
} else {
385
388
auto *FD = dyn_cast_or_null<AbstractFunctionDecl>(Result.FuncD );
Original file line number Diff line number Diff line change @@ -133,3 +133,10 @@ func testSettableSub(x: inout HasSettableSub) {
133
133
// SETTABLE_SUBSCRIPT-DAG: Pattern/CurrNominal/Flair[ArgLabels]: ['[']{#keyPath: KeyPath<HasSettableSub, Value>#}[']'][#Value#];
134
134
// SETTABLE_SUBSCRIPT-DAG: Decl[Subscript]/CurrNominal/Flair[ArgLabels]: ['[']{#(a): String#}[']'][#@lvalue Int#];
135
135
// SETTABLE_SUBSCRIPT-DAG: Decl[LocalVar]/Local/TypeRelation[Convertible]: local[#String#]; name=local
136
+
137
+ // rdar://139333904 - Make sure we don't hit an assertion.
138
+ func testFnKeyPathSubscript( ) {
139
+ // The keyPath: subscript is supported on all non-nominal types, including functions.
140
+ test1 [ #^FN_KEYPATH_SUBSCRIPT^#]
141
+ // FN_KEYPATH_SUBSCRIPT: Pattern/None/Flair[ArgLabels]: ['[']{#keyPath: KeyPath<() -> (), Value>#}[']'][#Value#]; name=keyPath:
142
+ }
You can’t perform that action at this time.
0 commit comments