File tree Expand file tree Collapse file tree 3 files changed +22
-16
lines changed Expand file tree Collapse file tree 3 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -2481,16 +2481,17 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2481
2481
// What's left is the result type.
2482
2482
if (ResultType->isVoid ()) {
2483
2483
OS << " Void" ;
2484
- } else if (!IsImplicitlyCurriedInstanceMethod
2485
- && FD->getAttrs ().hasAttribute <ImplicitlyUnwrappedOptionalAttr>()) {
2484
+ } else {
2486
2485
// As we did with parameters in addParamPatternFromFunction,
2487
2486
// for regular methods we'll print '!' after implicitly
2488
2487
// unwrapped optional results.
2489
- auto ObjectType = ResultType->getOptionalObjectType ();
2490
- OS << ObjectType->getStringAsComponent ();
2491
- OS << " !" ;
2492
- } else {
2493
- ResultType.print (OS);
2488
+ bool IsIUO =
2489
+ !IsImplicitlyCurriedInstanceMethod &&
2490
+ FD->getAttrs ().hasAttribute <ImplicitlyUnwrappedOptionalAttr>();
2491
+
2492
+ PrintOptions PO;
2493
+ PO.PrintOptionalAsImplicitlyUnwrapped = IsIUO;
2494
+ ResultType.print (OS, PO);
2494
2495
}
2495
2496
}
2496
2497
Builder.addTypeAnnotation (TypeStr);
Original file line number Diff line number Diff line change @@ -372,13 +372,8 @@ class CodeCompletionResultBuilder {
372
372
373
373
PrintOptions PO;
374
374
PO.SkipAttributes = true ;
375
- std::string TypeName;
376
- if (IsIUO) {
377
- assert (Ty->getOptionalObjectType ());
378
- TypeName = Ty->getOptionalObjectType ()->getStringAsComponent (PO) + " !" ;
379
- } else {
380
- TypeName = Ty->getString (PO);
381
- }
375
+ PO.PrintOptionalAsImplicitlyUnwrapped = IsIUO;
376
+ std::string TypeName = Ty->getString (PO);
382
377
addChunkWithText (CodeCompletionString::Chunk::ChunkKind::CallParameterType,
383
378
TypeName);
384
379
Original file line number Diff line number Diff line change @@ -308,18 +308,28 @@ func test_28188259(x: ((Int) -> Void) -> Void) {
308
308
func test_40956846(
309
309
arg_40956846_1: inout Int ! ,
310
310
arg_40956846_2: Void ! ,
311
- arg_40956846_3: ( ( ) -> Int ) ! ,
311
+ arg_40956846_3: ( ( ) -> Int ? ) ! ,
312
312
arg_40956846_4: inout ( ( Int ) -> Int ) !
313
313
) {
314
314
let y = #^RDAR_40956846 ^#
315
315
}
316
316
// RDAR_40956846: Begin completions
317
317
// RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_1[#inout Int!#]; name=arg_40956846_1
318
318
// RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_2[#Void!#]; name=arg_40956846_2
319
- // RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_3[#(() -> Int)!#]; name=arg_40956846_3
319
+ // RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_3[#(() -> Int? )!#]; name=arg_40956846_3
320
320
// RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_4[#inout ((Int) -> Int)!#]; name=arg_40956846_4
321
321
// RDAR_40956846: End completions
322
322
323
+ // rdar://problem/42443512
324
+ // RUN: %target-swift-ide-test -code-completion -code-completion-token=RDAR_42443512 -source-filename=%s | %FileCheck %s -check-prefix=RDAR_42443512
325
+ class test_42443512 {
326
+ func foo( x: Int ! ) { }
327
+ static func test( ) {
328
+ self . foo#^RDAR_42443512^#
329
+ }
330
+ }
331
+ // RDAR_42443512: Begin completions
332
+
323
333
// rdar://problem/42452085
324
334
// RUN: %target-swift-ide-test -code-completion -code-completion-token=RDAR_42452085_1 -source-filename=%s | %FileCheck %s -check-prefix=RDAR_42452085
325
335
// RUN: %target-swift-ide-test -code-completion -code-completion-token=RDAR_42452085_2 -source-filename=%s | %FileCheck %s -check-prefix=RDAR_42452085
You can’t perform that action at this time.
0 commit comments