@@ -1171,14 +1171,14 @@ calculateMaxTypeRelation(Type Ty, const ExpectedTypeContext &typeContext,
1171
1171
//
1172
1172
// { ... -> Int in x } // x must be Int
1173
1173
// { ... -> () in return x } // x must be Void
1174
- if (typeContext.isSingleExpressionBody && expectedTy->isVoid ())
1174
+ if (typeContext.isImplicitSingleExpressionReturn && expectedTy->isVoid ())
1175
1175
continue ;
1176
1176
1177
1177
Result = std::max (Result, calculateTypeRelation (Ty, expectedTy, DC));
1178
1178
1179
1179
// Map invalid -> unrelated when in a single-expression body, since the
1180
1180
// input may be incomplete.
1181
- if (typeContext.isSingleExpressionBody &&
1181
+ if (typeContext.isImplicitSingleExpressionReturn &&
1182
1182
Result == CodeCompletionResult::ExpectedTypeRelation::Invalid)
1183
1183
Result = CodeCompletionResult::ExpectedTypeRelation::Unrelated;
1184
1184
}
@@ -1958,9 +1958,11 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
1958
1958
IsStaticMetatype = value;
1959
1959
}
1960
1960
1961
- void setExpectedTypes (ArrayRef<Type> Types, bool isSingleExpressionBody,
1961
+ void setExpectedTypes (ArrayRef<Type> Types,
1962
+ bool isImplicitSingleExpressionReturn,
1962
1963
bool preferNonVoid = false ) {
1963
- expectedTypeContext.isSingleExpressionBody = isSingleExpressionBody;
1964
+ expectedTypeContext.isImplicitSingleExpressionReturn =
1965
+ isImplicitSingleExpressionReturn;
1964
1966
expectedTypeContext.preferNonVoid = preferNonVoid;
1965
1967
expectedTypeContext.possibleTypes .clear ();
1966
1968
expectedTypeContext.possibleTypes .reserve (Types.size ());
@@ -1976,7 +1978,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
1976
1978
CodeCompletionContext::TypeContextKind typeContextKind () const {
1977
1979
if (expectedTypeContext.empty () && !expectedTypeContext.preferNonVoid ) {
1978
1980
return CodeCompletionContext::TypeContextKind::None;
1979
- } else if (expectedTypeContext.isSingleExpressionBody ) {
1981
+ } else if (expectedTypeContext.isImplicitSingleExpressionReturn ) {
1980
1982
return CodeCompletionContext::TypeContextKind::SingleExpressionBody;
1981
1983
} else {
1982
1984
return CodeCompletionContext::TypeContextKind::Required;
@@ -6105,7 +6107,7 @@ void deliverUnresolvedMemberResults(
6105
6107
6106
6108
for (auto &Result: Results) {
6107
6109
Lookup.setExpectedTypes ({Result.ExpectedTy },
6108
- Result.IsSingleExpressionBody ,
6110
+ Result.IsImplicitSingleExpressionReturn ,
6109
6111
/* expectsNonVoid*/ true );
6110
6112
Lookup.setIdealExpectedType (Result.ExpectedTy );
6111
6113
@@ -6154,7 +6156,7 @@ void deliverDotExprResults(
6154
6156
Lookup.setIsStaticMetatype (Result.BaseIsStaticMetaType );
6155
6157
Lookup.getPostfixKeywordCompletions (Result.BaseTy , BaseExpr);
6156
6158
Lookup.setExpectedTypes (Result.ExpectedTypes ,
6157
- Result.IsSingleExpressionBody ,
6159
+ Result.IsImplicitSingleExpressionReturn ,
6158
6160
Result.ExpectsNonVoid );
6159
6161
if (isDynamicLookup (Result.BaseTy ))
6160
6162
Lookup.setIsDynamicLookup ();
@@ -6395,7 +6397,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
6395
6397
case CompletionKind::PostfixExprBeginning: {
6396
6398
ExprContextInfo ContextInfo (CurDeclContext, CodeCompleteTokenExpr);
6397
6399
Lookup.setExpectedTypes (ContextInfo.getPossibleTypes (),
6398
- ContextInfo.isSingleExpressionBody ());
6400
+ ContextInfo.isImplicitSingleExpressionReturn ());
6399
6401
DoPostfixExprBeginning ();
6400
6402
break ;
6401
6403
}
@@ -6417,8 +6419,9 @@ void CodeCompletionCallbacksImpl::doneParsing() {
6417
6419
6418
6420
if (ShouldCompleteCallPatternAfterParen) {
6419
6421
ExprContextInfo ParentContextInfo (CurDeclContext, ParsedExpr);
6420
- Lookup.setExpectedTypes (ParentContextInfo.getPossibleTypes (),
6421
- ParentContextInfo.isSingleExpressionBody ());
6422
+ Lookup.setExpectedTypes (
6423
+ ParentContextInfo.getPossibleTypes (),
6424
+ ParentContextInfo.isImplicitSingleExpressionReturn ());
6422
6425
if (!ContextInfo.getPossibleCallees ().empty ()) {
6423
6426
for (auto &typeAndDecl : ContextInfo.getPossibleCallees ())
6424
6427
Lookup.tryFunctionCallCompletions (typeAndDecl.Type , typeAndDecl.Decl ,
@@ -6436,7 +6439,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
6436
6439
(Lookup.FoundFunctionCalls &&
6437
6440
Lookup.FoundFunctionsWithoutFirstKeyword )) {
6438
6441
Lookup.setExpectedTypes (ContextInfo.getPossibleTypes (),
6439
- ContextInfo.isSingleExpressionBody ());
6442
+ ContextInfo.isImplicitSingleExpressionReturn ());
6440
6443
Lookup.setHaveLParen (false );
6441
6444
DoPostfixExprBeginning ();
6442
6445
}
@@ -6485,7 +6488,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
6485
6488
case CompletionKind::CaseStmtBeginning: {
6486
6489
ExprContextInfo ContextInfo (CurDeclContext, CodeCompleteTokenExpr);
6487
6490
Lookup.setExpectedTypes (ContextInfo.getPossibleTypes (),
6488
- ContextInfo.isSingleExpressionBody ());
6491
+ ContextInfo.isImplicitSingleExpressionReturn ());
6489
6492
Lookup.setIdealExpectedType (CodeCompleteTokenExpr->getType ());
6490
6493
Lookup.getUnresolvedMemberCompletions (ContextInfo.getPossibleTypes ());
6491
6494
DoPostfixExprBeginning ();
@@ -6504,7 +6507,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
6504
6507
if (isa<AccessorDecl>(ParsedDecl)) {
6505
6508
ExprContextInfo ContextInfo (CurDeclContext, CodeCompleteTokenExpr);
6506
6509
Lookup.setExpectedTypes (ContextInfo.getPossibleTypes (),
6507
- ContextInfo.isSingleExpressionBody ());
6510
+ ContextInfo.isImplicitSingleExpressionReturn ());
6508
6511
DoPostfixExprBeginning ();
6509
6512
}
6510
6513
break ;
@@ -6578,7 +6581,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
6578
6581
6579
6582
if (shouldPerformGlobalCompletion) {
6580
6583
Lookup.setExpectedTypes (ContextInfo.getPossibleTypes (),
6581
- ContextInfo.isSingleExpressionBody ());
6584
+ ContextInfo.isImplicitSingleExpressionReturn ());
6582
6585
DoPostfixExprBeginning ();
6583
6586
}
6584
6587
break ;
@@ -6697,7 +6700,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
6697
6700
SmallVector<Type, 2 > possibleReturnTypes;
6698
6701
collectPossibleReturnTypesFromContext (CurDeclContext, possibleReturnTypes);
6699
6702
Lookup.setExpectedTypes (possibleReturnTypes,
6700
- /* isSingleExpressionBody */ false );
6703
+ /* isImplicitSingleExpressionReturn */ false );
6701
6704
Lookup.getValueCompletionsInDeclContext (Loc);
6702
6705
break ;
6703
6706
}
@@ -6708,7 +6711,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
6708
6711
if (FD->isCoroutine ()) {
6709
6712
// TODO: handle multi-value yields.
6710
6713
Lookup.setExpectedTypes (FD->getStorage ()->getValueInterfaceType (),
6711
- /* isSingleExpressionBody */ false );
6714
+ /* isImplicitSingleExpressionReturn */ false );
6712
6715
}
6713
6716
}
6714
6717
Lookup.getValueCompletionsInDeclContext (Loc);
@@ -6718,7 +6721,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
6718
6721
case CompletionKind::AfterPoundExpr: {
6719
6722
ExprContextInfo ContextInfo (CurDeclContext, CodeCompleteTokenExpr);
6720
6723
Lookup.setExpectedTypes (ContextInfo.getPossibleTypes (),
6721
- ContextInfo.isSingleExpressionBody ());
6724
+ ContextInfo.isImplicitSingleExpressionReturn ());
6722
6725
6723
6726
Lookup.addPoundAvailable (ParentStmtKind);
6724
6727
Lookup.addPoundLiteralCompletions (/* needPound=*/ false );
0 commit comments