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 @@ -2559,16 +2559,17 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2559
2559
// What's left is the result type.
2560
2560
if (ResultType->isVoid ()) {
2561
2561
OS << " Void" ;
2562
- } else if (!IsImplicitlyCurriedInstanceMethod
2563
- && FD->getAttrs ().hasAttribute <ImplicitlyUnwrappedOptionalAttr>()) {
2562
+ } else {
2564
2563
// As we did with parameters in addParamPatternFromFunction,
2565
2564
// for regular methods we'll print '!' after implicitly
2566
2565
// unwrapped optional results.
2567
- auto ObjectType = ResultType->getOptionalObjectType ();
2568
- OS << ObjectType->getStringAsComponent ();
2569
- OS << " !" ;
2570
- } else {
2571
- ResultType.print (OS);
2566
+ bool IsIUO =
2567
+ !IsImplicitlyCurriedInstanceMethod &&
2568
+ FD->getAttrs ().hasAttribute <ImplicitlyUnwrappedOptionalAttr>();
2569
+
2570
+ PrintOptions PO;
2571
+ PO.PrintOptionalAsImplicitlyUnwrapped = IsIUO;
2572
+ ResultType.print (OS, PO);
2572
2573
}
2573
2574
}
2574
2575
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 @@ -306,18 +306,28 @@ func test_28188259(x: ((Int) -> Void) -> Void) {
306
306
func test_40956846(
307
307
arg_40956846_1: inout Int ! ,
308
308
arg_40956846_2: Void ! ,
309
- arg_40956846_3: ( ( ) -> Int ) ! ,
309
+ arg_40956846_3: ( ( ) -> Int ? ) ! ,
310
310
arg_40956846_4: inout ( ( Int ) -> Int ) !
311
311
) {
312
312
let y = #^RDAR_40956846 ^#
313
313
}
314
314
// RDAR_40956846: Begin completions
315
315
// RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_1[#inout Int!#]; name=arg_40956846_1
316
316
// RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_2[#Void!#]; name=arg_40956846_2
317
- // RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_3[#(() -> Int)!#]; name=arg_40956846_3
317
+ // RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_3[#(() -> Int? )!#]; name=arg_40956846_3
318
318
// RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_4[#inout ((Int) -> Int)!#]; name=arg_40956846_4
319
319
// RDAR_40956846: End completions
320
320
321
+ // rdar://problem/42443512
322
+ // RUN: %target-swift-ide-test -code-completion -code-completion-token=RDAR_42443512 -source-filename=%s | %FileCheck %s -check-prefix=RDAR_42443512
323
+ class test_42443512 {
324
+ func foo( x: Int ! ) { }
325
+ static func test( ) {
326
+ self . foo#^RDAR_42443512^#
327
+ }
328
+ }
329
+ // RDAR_42443512: Begin completions
330
+
321
331
// rdar://problem/42452085
322
332
// RUN: %target-swift-ide-test -code-completion -code-completion-token=RDAR_42452085_1 -source-filename=%s | %FileCheck %s -check-prefix=RDAR_42452085
323
333
// 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