@@ -1923,6 +1923,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
1923
1923
PrintOptions PO;
1924
1924
PO.OpaqueReturnTypePrinting =
1925
1925
PrintOptions::OpaqueReturnTypePrintingMode::WithoutOpaqueKeyword;
1926
+ if (auto typeContext = CurrDeclContext->getInnermostTypeContext ())
1927
+ PO.setBaseType (typeContext->getDeclaredTypeInContext ());
1926
1928
Builder.addTypeAnnotation (T.getString (PO));
1927
1929
}
1928
1930
}
@@ -1944,6 +1946,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
1944
1946
PO.PrintOptionalAsImplicitlyUnwrapped = true ;
1945
1947
PO.OpaqueReturnTypePrinting =
1946
1948
PrintOptions::OpaqueReturnTypePrintingMode::WithoutOpaqueKeyword;
1949
+ if (auto typeContext = CurrDeclContext->getInnermostTypeContext ())
1950
+ PO.setBaseType (typeContext->getDeclaredTypeInContext ());
1947
1951
Builder.addTypeAnnotation (T.getString (PO) + suffix);
1948
1952
}
1949
1953
@@ -2288,9 +2292,12 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2288
2292
2289
2293
if (NeedComma)
2290
2294
Builder.addComma ();
2295
+ Type contextTy;
2296
+ if (auto typeContext = CurrDeclContext->getInnermostTypeContext ())
2297
+ contextTy = typeContext->getDeclaredTypeInContext ();
2291
2298
2292
- Builder.addCallParameter (argName, bodyName, paramTy, isVariadic, isInOut ,
2293
- isIUO, isAutoclosure);
2299
+ Builder.addCallParameter (argName, bodyName, paramTy, contextTy ,
2300
+ isVariadic, isInOut, isIUO, isAutoclosure);
2294
2301
2295
2302
modifiedBuilder = true ;
2296
2303
NeedComma = true ;
@@ -2636,6 +2643,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2636
2643
PO.OpaqueReturnTypePrinting =
2637
2644
PrintOptions::OpaqueReturnTypePrintingMode::WithoutOpaqueKeyword;
2638
2645
PO.PrintOptionalAsImplicitlyUnwrapped = IsIUO;
2646
+ if (auto typeContext = CurrDeclContext->getInnermostTypeContext ())
2647
+ PO.setBaseType (typeContext->getDeclaredTypeInContext ());
2639
2648
ResultType.print (OS, PO);
2640
2649
}
2641
2650
}
@@ -3472,9 +3481,10 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3472
3481
builder.addEqual ();
3473
3482
builder.addWhitespace (" " );
3474
3483
assert (RHSType && resultType);
3475
- builder.addCallParameter (Identifier (), Identifier (), RHSType,
3476
- /* IsVarArg*/ false , /* IsInOut*/ false ,
3477
- /* isIUO*/ false , /* isAutoClosure*/ false );
3484
+ Type contextTy;
3485
+ if (auto typeContext = CurrDeclContext->getInnermostTypeContext ())
3486
+ contextTy = typeContext->getDeclaredTypeInContext ();
3487
+ builder.addCallParameter (Identifier (), RHSType, contextTy);
3478
3488
addTypeAnnotation (builder, resultType);
3479
3489
}
3480
3490
@@ -3495,10 +3505,12 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3495
3505
builder.addWhitespace (" " );
3496
3506
builder.addTextChunk (op->getName ().str ());
3497
3507
builder.addWhitespace (" " );
3498
- if (RHSType)
3499
- builder.addCallParameter (Identifier (), Identifier (), RHSType,
3500
- /* IsVarArg*/ false , /* IsInOut*/ false ,
3501
- /* isIUO*/ false , /* isAutoClosure*/ false );
3508
+ if (RHSType) {
3509
+ Type contextTy;
3510
+ if (auto typeContext = CurrDeclContext->getInnermostTypeContext ())
3511
+ contextTy = typeContext->getDeclaredTypeInContext ();
3512
+ builder.addCallParameter (Identifier (), RHSType, contextTy);
3513
+ }
3502
3514
if (resultType)
3503
3515
addTypeAnnotation (builder, resultType);
3504
3516
}
@@ -3722,21 +3734,13 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3722
3734
addFromProto (LK::ColorLiteral, " " , [&](Builder &builder) {
3723
3735
builder.addTextChunk (" #colorLiteral" );
3724
3736
builder.addLeftParen ();
3725
- builder.addCallParameter (context.getIdentifier (" red" ), floatType,
3726
- /* IsVarArg*/ false , /* IsInOut*/ false ,
3727
- /* isIUO*/ false , /* isAutoClosure*/ false );
3737
+ builder.addCallParameter (context.getIdentifier (" red" ), floatType);
3728
3738
builder.addComma ();
3729
- builder.addCallParameter (context.getIdentifier (" green" ), floatType,
3730
- /* IsVarArg*/ false , /* IsInOut*/ false ,
3731
- /* isIUO*/ false , /* isAutoClosure*/ false );
3739
+ builder.addCallParameter (context.getIdentifier (" green" ), floatType);
3732
3740
builder.addComma ();
3733
- builder.addCallParameter (context.getIdentifier (" blue" ), floatType,
3734
- /* IsVarArg*/ false , /* IsInOut*/ false ,
3735
- /* isIUO*/ false , /* isAutoClosure*/ false );
3741
+ builder.addCallParameter (context.getIdentifier (" blue" ), floatType);
3736
3742
builder.addComma ();
3737
- builder.addCallParameter (context.getIdentifier (" alpha" ), floatType,
3738
- /* IsVarArg*/ false , /* IsInOut*/ false ,
3739
- /* isIUO*/ false , /* isAutoClosure*/ false );
3743
+ builder.addCallParameter (context.getIdentifier (" alpha" ), floatType);
3740
3744
builder.addRightParen ();
3741
3745
});
3742
3746
@@ -3745,9 +3749,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3745
3749
builder.addTextChunk (" #imageLiteral" );
3746
3750
builder.addLeftParen ();
3747
3751
builder.addCallParameter (context.getIdentifier (" resourceName" ),
3748
- stringType, /* IsVarArg*/ false ,
3749
- /* IsInOut*/ false , /* isIUO*/ false ,
3750
- /* isAutoClosure*/ false );
3752
+ stringType);
3751
3753
builder.addRightParen ();
3752
3754
});
3753
3755
@@ -4391,6 +4393,8 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
4391
4393
{
4392
4394
llvm::raw_svector_ostream OS (DeclStr);
4393
4395
PrintOptions Options;
4396
+ if (auto transformType = CurrDeclContext->getDeclaredTypeInContext ())
4397
+ Options.setBaseType (transformType);
4394
4398
Options.PrintImplicitAttrs = false ;
4395
4399
Options.SkipAttributes = true ;
4396
4400
CD->print (OS, Options);
0 commit comments