@@ -600,19 +600,19 @@ void CodeCompletionResult::printPrefix(raw_ostream &OS) const {
600
600
Prefix.append (" ]" );
601
601
}
602
602
switch (getExpectedTypeRelation ()) {
603
- case ExpectedTypeRelation ::Invalid:
604
- Prefix.append (" /TypeRelation[Invalid]" );
605
- break ;
606
- case ExpectedTypeRelation ::Identical:
607
- Prefix.append (" /TypeRelation[Identical]" );
608
- break ;
609
- case ExpectedTypeRelation ::Convertible:
610
- Prefix.append (" /TypeRelation[Convertible]" );
611
- break ;
612
- case ExpectedTypeRelation ::NotApplicable:
613
- case ExpectedTypeRelation ::Unknown:
614
- case ExpectedTypeRelation ::Unrelated:
615
- break ;
603
+ case CodeCompletionResultTypeRelation ::Invalid:
604
+ Prefix.append (" /TypeRelation[Invalid]" );
605
+ break ;
606
+ case CodeCompletionResultTypeRelation ::Identical:
607
+ Prefix.append (" /TypeRelation[Identical]" );
608
+ break ;
609
+ case CodeCompletionResultTypeRelation ::Convertible:
610
+ Prefix.append (" /TypeRelation[Convertible]" );
611
+ break ;
612
+ case CodeCompletionResultTypeRelation ::NotApplicable:
613
+ case CodeCompletionResultTypeRelation ::Unknown:
614
+ case CodeCompletionResultTypeRelation ::Unrelated:
615
+ break ;
616
616
}
617
617
618
618
Prefix.append (" : " );
@@ -1141,44 +1141,44 @@ ArrayRef<StringRef> copyAssociatedUSRs(llvm::BumpPtrAllocator &Allocator,
1141
1141
return ArrayRef<StringRef>();
1142
1142
}
1143
1143
1144
- static CodeCompletionResult::ExpectedTypeRelation
1144
+ static CodeCompletionResultTypeRelation
1145
1145
calculateTypeRelation (Type Ty, Type ExpectedTy, const DeclContext *DC) {
1146
1146
if (Ty.isNull () || ExpectedTy.isNull () ||
1147
1147
Ty->is <ErrorType>() ||
1148
1148
ExpectedTy->is <ErrorType>())
1149
- return CodeCompletionResult::ExpectedTypeRelation ::Unrelated;
1149
+ return CodeCompletionResultTypeRelation ::Unrelated;
1150
1150
1151
1151
// Equality/Conversion of GenericTypeParameterType won't account for
1152
1152
// requirements – ignore them
1153
1153
if (!Ty->hasTypeParameter () && !ExpectedTy->hasTypeParameter ()) {
1154
1154
if (Ty->isEqual (ExpectedTy))
1155
- return CodeCompletionResult::ExpectedTypeRelation ::Identical;
1155
+ return CodeCompletionResultTypeRelation ::Identical;
1156
1156
bool isAny = false ;
1157
1157
isAny |= ExpectedTy->isAny ();
1158
1158
isAny |= ExpectedTy->is <ArchetypeType>() &&
1159
1159
!ExpectedTy->castTo <ArchetypeType>()->hasRequirements ();
1160
1160
1161
1161
if (!isAny && isConvertibleTo (Ty, ExpectedTy, /* openArchetypes=*/ true ,
1162
1162
*const_cast <DeclContext *>(DC)))
1163
- return CodeCompletionResult::ExpectedTypeRelation ::Convertible;
1163
+ return CodeCompletionResultTypeRelation ::Convertible;
1164
1164
}
1165
1165
if (auto FT = Ty->getAs <AnyFunctionType>()) {
1166
1166
if (FT->getResult ()->isVoid ())
1167
- return CodeCompletionResult::ExpectedTypeRelation ::Invalid;
1167
+ return CodeCompletionResultTypeRelation ::Invalid;
1168
1168
}
1169
- return CodeCompletionResult::ExpectedTypeRelation ::Unrelated;
1169
+ return CodeCompletionResultTypeRelation ::Unrelated;
1170
1170
}
1171
1171
1172
- static CodeCompletionResult::ExpectedTypeRelation
1172
+ static CodeCompletionResultTypeRelation
1173
1173
calculateMaxTypeRelation (Type Ty, const ExpectedTypeContext &typeContext,
1174
1174
const DeclContext *DC) {
1175
1175
if (typeContext.empty ())
1176
- return CodeCompletionResult::ExpectedTypeRelation ::Unknown;
1176
+ return CodeCompletionResultTypeRelation ::Unknown;
1177
1177
1178
1178
if (auto funcTy = Ty->getAs <AnyFunctionType>())
1179
1179
Ty = funcTy->removeArgumentLabels (1 );
1180
1180
1181
- auto Result = CodeCompletionResult::ExpectedTypeRelation ::Unrelated;
1181
+ auto Result = CodeCompletionResultTypeRelation ::Unrelated;
1182
1182
for (auto expectedTy : typeContext.possibleTypes ) {
1183
1183
// Do not use Void type context for a single-expression body, since the
1184
1184
// implicit return does not constrain the expression.
@@ -1197,8 +1197,8 @@ calculateMaxTypeRelation(Type Ty, const ExpectedTypeContext &typeContext,
1197
1197
// Map invalid -> unrelated when in a single-expression body, since the
1198
1198
// input may be incomplete.
1199
1199
if (typeContext.isImplicitSingleExpressionReturn &&
1200
- Result == CodeCompletionResult::ExpectedTypeRelation ::Invalid)
1201
- Result = CodeCompletionResult::ExpectedTypeRelation ::Unrelated;
1200
+ Result == CodeCompletionResultTypeRelation ::Invalid)
1201
+ Result = CodeCompletionResultTypeRelation ::Unrelated;
1202
1202
}
1203
1203
return Result;
1204
1204
}
@@ -2914,7 +2914,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2914
2914
Builder.addTypeAnnotation (" Selector" );
2915
2915
// This function is called only if the context type is 'Selector'.
2916
2916
Builder.setExpectedTypeRelation (
2917
- CodeCompletionResult::ExpectedTypeRelation ::Identical);
2917
+ CodeCompletionResultTypeRelation ::Identical);
2918
2918
}
2919
2919
2920
2920
void addPoundKeyPath (bool needPound) {
@@ -2934,7 +2934,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2934
2934
Builder.addTypeAnnotation (" String" );
2935
2935
// This function is called only if the context type is 'String'.
2936
2936
Builder.setExpectedTypeRelation (
2937
- CodeCompletionResult::ExpectedTypeRelation ::Identical);
2937
+ CodeCompletionResultTypeRelation ::Identical);
2938
2938
}
2939
2939
2940
2940
SemanticContextKind getSemanticContextKind (const ValueDecl *VD) {
@@ -3276,7 +3276,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3276
3276
expectedTypeContext.requiresNonVoid () &&
3277
3277
ResultType->isVoid ()) {
3278
3278
Builder.setExpectedTypeRelation (
3279
- CodeCompletionResult::ExpectedTypeRelation ::Invalid);
3279
+ CodeCompletionResultTypeRelation ::Invalid);
3280
3280
}
3281
3281
};
3282
3282
@@ -3655,7 +3655,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3655
3655
auto maxRel = calculateMaxTypeRelation (funcTy, expectedTypeContext,
3656
3656
CurrDeclContext);
3657
3657
useFunctionReference =
3658
- maxRel >= CodeCompletionResult::ExpectedTypeRelation ::Convertible;
3658
+ maxRel >= CodeCompletionResultTypeRelation ::Convertible;
3659
3659
}
3660
3660
if (!useFunctionReference)
3661
3661
return false ;
@@ -4325,14 +4325,13 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
4325
4325
if (!T)
4326
4326
continue ;
4327
4327
4328
- auto typeRelation = CodeCompletionResult::ExpectedTypeRelation ::Identical;
4328
+ auto typeRelation = CodeCompletionResultTypeRelation ::Identical;
4329
4329
// Convert through optional types unless we're looking for a protocol
4330
4330
// that Optional itself conforms to.
4331
4331
if (kind != CodeCompletionLiteralKind::NilLiteral) {
4332
4332
if (auto optionalObjT = T->getOptionalObjectType ()) {
4333
4333
T = optionalObjT;
4334
- typeRelation =
4335
- CodeCompletionResult::ExpectedTypeRelation::Convertible;
4334
+ typeRelation = CodeCompletionResultTypeRelation::Convertible;
4336
4335
}
4337
4336
}
4338
4337
@@ -4352,8 +4351,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
4352
4351
builder.addTypeAnnotation (defaultTy, PrintOptions ());
4353
4352
builder.setExpectedTypeRelation (
4354
4353
expectedTypeContext.possibleTypes .empty ()
4355
- ? CodeCompletionResult::ExpectedTypeRelation ::Unknown
4356
- : CodeCompletionResult::ExpectedTypeRelation ::Unrelated);
4354
+ ? CodeCompletionResultTypeRelation ::Unknown
4355
+ : CodeCompletionResultTypeRelation ::Unrelated);
4357
4356
}
4358
4357
}
4359
4358
@@ -4511,7 +4510,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
4511
4510
if (T && T->is <TupleType>() && !T->isVoid ()) {
4512
4511
addTypeAnnotation (builder, T);
4513
4512
builder.setExpectedTypeRelation (
4514
- CodeCompletionResult::ExpectedTypeRelation ::Identical);
4513
+ CodeCompletionResultTypeRelation ::Identical);
4515
4514
break ;
4516
4515
}
4517
4516
}
@@ -4736,7 +4735,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
4736
4735
}
4737
4736
addTypeAnnotation (Builder, Ty);
4738
4737
Builder.setExpectedTypeRelation (
4739
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable);
4738
+ CodeCompletionResultTypeRelation ::NotApplicable);
4740
4739
}
4741
4740
}
4742
4741
@@ -5342,7 +5341,7 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
5342
5341
CodeCompletionResultKind::Declaration,
5343
5342
SemanticContextKind::Super, {});
5344
5343
Builder.setExpectedTypeRelation (
5345
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable);
5344
+ CodeCompletionResultTypeRelation ::NotApplicable);
5346
5345
Builder.setAssociatedDecl (FD);
5347
5346
addValueOverride (FD, Reason, dynamicLookupInfo, Builder, hasFuncIntroducer);
5348
5347
Builder.addBraceStmtWithCursor ();
@@ -5371,7 +5370,7 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
5371
5370
CodeCompletionResultKind::Declaration,
5372
5371
SemanticContextKind::Super, {});
5373
5372
Builder.setExpectedTypeRelation (
5374
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable);
5373
+ CodeCompletionResultTypeRelation ::NotApplicable);
5375
5374
Builder.setAssociatedDecl (SD);
5376
5375
addValueOverride (SD, Reason, dynamicLookupInfo, Builder, false );
5377
5376
Builder.addBraceStmtWithCursor ();
@@ -5383,7 +5382,7 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
5383
5382
CodeCompletionResultKind::Declaration,
5384
5383
SemanticContextKind::Super, {});
5385
5384
Builder.setExpectedTypeRelation (
5386
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable);
5385
+ CodeCompletionResultTypeRelation ::NotApplicable);
5387
5386
Builder.setAssociatedDecl (ATD);
5388
5387
if (!hasTypealiasIntroducer && !hasAccessModifier)
5389
5388
(void )addAccessControl (ATD, Builder);
@@ -5400,7 +5399,7 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
5400
5399
CodeCompletionResultKind::Declaration,
5401
5400
SemanticContextKind::Super, {});
5402
5401
Builder.setExpectedTypeRelation (
5403
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable);
5402
+ CodeCompletionResultTypeRelation ::NotApplicable);
5404
5403
Builder.setAssociatedDecl (CD);
5405
5404
5406
5405
CodeCompletionStringPrinter printer (Builder);
@@ -5600,7 +5599,7 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
5600
5599
SemanticContextKind::CurrentNominal,
5601
5600
{});
5602
5601
Builder.setExpectedTypeRelation (
5603
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable);
5602
+ CodeCompletionResultTypeRelation ::NotApplicable);
5604
5603
5605
5604
if (!hasFuncIntroducer) {
5606
5605
if (!hasAccessModifier &&
@@ -6034,12 +6033,12 @@ static bool isClangSubModule(ModuleDecl *TheModule) {
6034
6033
return false ;
6035
6034
}
6036
6035
6037
- static void
6038
- addKeyword (CodeCompletionResultSink &Sink, StringRef Name ,
6039
- CodeCompletionKeywordKind Kind, StringRef TypeAnnotation = " " ,
6040
- CodeCompletionResult::ExpectedTypeRelation TypeRelation =
6041
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable,
6042
- CodeCompletionFlair Flair = {}) {
6036
+ static void addKeyword (CodeCompletionResultSink &Sink, StringRef Name,
6037
+ CodeCompletionKeywordKind Kind ,
6038
+ StringRef TypeAnnotation = " " ,
6039
+ CodeCompletionResultTypeRelation TypeRelation =
6040
+ CodeCompletionResultTypeRelation ::NotApplicable,
6041
+ CodeCompletionFlair Flair = {}) {
6043
6042
CodeCompletionResultBuilder Builder (Sink, CodeCompletionResultKind::Keyword,
6044
6043
SemanticContextKind::None, {});
6045
6044
Builder.setKeywordKind (Kind);
@@ -6178,10 +6177,9 @@ static void addDeclKeywords(CodeCompletionResultSink &Sink, DeclContext *DC,
6178
6177
DeclAttribute::isDistributedOnly (*DAK))
6179
6178
return ;
6180
6179
6181
- addKeyword (
6182
- Sink, Name, Kind, /* TypeAnnotation=*/ " " ,
6183
- /* TypeRelation=*/ CodeCompletionResult::ExpectedTypeRelation::NotApplicable,
6184
- getFlair (Kind, DAK));
6180
+ addKeyword (Sink, Name, Kind, /* TypeAnnotation=*/ " " ,
6181
+ /* TypeRelation=*/ CodeCompletionResultTypeRelation::NotApplicable,
6182
+ getFlair (Kind, DAK));
6185
6183
};
6186
6184
6187
6185
#define DECL_KEYWORD (kw ) \
@@ -6213,8 +6211,7 @@ static void addStmtKeywords(CodeCompletionResultSink &Sink, DeclContext *DC,
6213
6211
if (!MaybeFuncBody && Kind == CodeCompletionKeywordKind::kw_return)
6214
6212
return ;
6215
6213
addKeyword (Sink, Name, Kind, " " ,
6216
- CodeCompletionResult::ExpectedTypeRelation::NotApplicable,
6217
- flair);
6214
+ CodeCompletionResultTypeRelation::NotApplicable, flair);
6218
6215
};
6219
6216
#define STMT_KEYWORD (kw ) AddStmtKeyword(#kw, CodeCompletionKeywordKind::kw_##kw);
6220
6217
#include " swift/Syntax/TokenKinds.def"
@@ -6249,13 +6246,13 @@ static void addExprKeywords(CodeCompletionResultSink &Sink, DeclContext *DC) {
6249
6246
6250
6247
// Expr keywords.
6251
6248
addKeyword (Sink, " try" , CodeCompletionKeywordKind::kw_try, " " ,
6252
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable, flair);
6249
+ CodeCompletionResultTypeRelation ::NotApplicable, flair);
6253
6250
addKeyword (Sink, " try!" , CodeCompletionKeywordKind::kw_try, " " ,
6254
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable, flair);
6251
+ CodeCompletionResultTypeRelation ::NotApplicable, flair);
6255
6252
addKeyword (Sink, " try?" , CodeCompletionKeywordKind::kw_try, " " ,
6256
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable, flair);
6253
+ CodeCompletionResultTypeRelation ::NotApplicable, flair);
6257
6254
addKeyword (Sink, " await" , CodeCompletionKeywordKind::None, " " ,
6258
- CodeCompletionResult::ExpectedTypeRelation ::NotApplicable, flair);
6255
+ CodeCompletionResultTypeRelation ::NotApplicable, flair);
6259
6256
}
6260
6257
6261
6258
static void addOpaqueTypeKeyword (CodeCompletionResultSink &Sink) {
@@ -7512,8 +7509,7 @@ copyCodeCompletionResults(CodeCompletionResultSink &targetSink,
7512
7509
auto contextualResult = new (*targetSink.Allocator ) CodeCompletionResult (
7513
7510
*contextFreeResult, SemanticContextKind::OtherModule,
7514
7511
CodeCompletionFlair (),
7515
- /* numBytesToErase=*/ 0 ,
7516
- CodeCompletionResult::ExpectedTypeRelation::Unknown,
7512
+ /* numBytesToErase=*/ 0 , CodeCompletionResultTypeRelation::Unknown,
7517
7513
ContextualNotRecommendedReason::None,
7518
7514
CodeCompletionDiagnosticSeverity::None, /* DiagnosticMessage=*/ " " );
7519
7515
targetSink.Results .push_back (contextualResult);
0 commit comments