Skip to content

Commit 21cfcfe

Browse files
authored
Merge pull request swiftlang#30505 from CodaFi/ligated-legacy
[NFC] Remove the Legacy Semantic Queries Bit
2 parents 06196e0 + 6d60d01 commit 21cfcfe

File tree

12 files changed

+9
-83
lines changed

12 files changed

+9
-83
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -332,32 +332,6 @@ class ASTContext final {
332332
llvm::BumpPtrAllocator &
333333
getAllocator(AllocationArena arena = AllocationArena::Permanent) const;
334334

335-
private:
336-
bool SemanticQueriesEnabled = false;
337-
338-
public:
339-
/// Returns \c true if legacy semantic AST queries are enabled.
340-
///
341-
/// The request evaluator generally subsumes the use of this bit. However,
342-
/// there are clients - mostly SourceKit - that rely on the fact that this bit
343-
/// being \c false causes some property wrapper requests to return null
344-
/// sentinel values. These clients should be migrated off of this interface
345-
/// to syntactic requests as soon as possible.
346-
///
347-
/// rdar://60516325
348-
bool areLegacySemanticQueriesEnabled() const {
349-
return SemanticQueriesEnabled;
350-
}
351-
352-
/// Enable "semantic queries".
353-
///
354-
/// Setting this bit tells property wrapper requests to return a semantic
355-
/// value. It does not otherwise affect compiler behavior and should be
356-
/// removed as soon as possible.
357-
void setLegacySemanticQueriesEnabled() {
358-
SemanticQueriesEnabled = true;
359-
}
360-
361335
public:
362336
/// Allocate - Allocate memory from the ASTContext bump pointer.
363337
void *Allocate(unsigned long bytes, unsigned alignment,

lib/AST/Decl.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,9 +2997,6 @@ bool ValueDecl::isRecursiveValidation() const {
29972997

29982998
Type ValueDecl::getInterfaceType() const {
29992999
auto &ctx = getASTContext();
3000-
3001-
assert(ctx.areLegacySemanticQueriesEnabled());
3002-
30033000
if (auto type =
30043001
evaluateOrDefault(ctx.evaluator,
30053002
InterfaceTypeRequest{const_cast<ValueDecl *>(this)},
@@ -5812,13 +5809,8 @@ StaticSpellingKind AbstractStorageDecl::getCorrectStaticSpelling() const {
58125809
}
58135810

58145811
llvm::TinyPtrVector<CustomAttr *> VarDecl::getAttachedPropertyWrappers() const {
5815-
auto &ctx = getASTContext();
5816-
if (!ctx.areLegacySemanticQueriesEnabled()) {
5817-
return { };
5818-
}
5819-
58205812
auto mutableThis = const_cast<VarDecl *>(this);
5821-
return evaluateOrDefault(ctx.evaluator,
5813+
return evaluateOrDefault(getASTContext().evaluator,
58225814
AttachedPropertyWrappersRequest{mutableThis},
58235815
{ });
58245816
}
@@ -6786,7 +6778,7 @@ ObjCSelector
67866778
AbstractFunctionDecl::getObjCSelector(DeclName preferredName,
67876779
bool skipIsObjCResolution) const {
67886780
// FIXME: Forces computation of the Objective-C selector.
6789-
if (getASTContext().areLegacySemanticQueriesEnabled() && !skipIsObjCResolution)
6781+
if (!skipIsObjCResolution)
67906782
(void)isObjC();
67916783

67926784
// If there is an @objc attribute with a name, use that name.

lib/AST/NameLookup.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,9 +1622,7 @@ QualifiedLookupRequest::evaluate(Evaluator &eval, const DeclContext *DC,
16221622
tracker->addUsedMember({current, member.getBaseName()},isLookupCascading);
16231623

16241624
// Make sure we've resolved property wrappers, if we need them.
1625-
if (ctx.areLegacySemanticQueriesEnabled()) {
1626-
installPropertyWrapperMembersIfNeeded(current, member);
1627-
}
1625+
installPropertyWrapperMembersIfNeeded(current, member);
16281626

16291627
// Look for results within the current nominal type and its extensions.
16301628
bool currentIsProtocol = isa<ProtocolDecl>(current);

lib/Frontend/Frontend.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ bool CompilerInstance::setUpASTContextIfNeeded() {
240240
if (setUpModuleLoaders())
241241
return true;
242242

243-
Context->setLegacySemanticQueriesEnabled();
244243
return false;
245244
}
246245

lib/IDE/CodeCompletion.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,8 +1659,6 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
16591659
Importer(static_cast<ClangImporter *>(CurrDeclContext->getASTContext().
16601660
getClangModuleLoader())),
16611661
CompletionContext(CompletionContext) {
1662-
Ctx.setLegacySemanticQueriesEnabled();
1663-
16641662
// Determine if we are doing code completion inside a static method.
16651663
if (CurrDeclContext) {
16661664
CurrentMethod = CurrDeclContext->getInnermostMethodContext();
@@ -4221,8 +4219,6 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
42214219
SourceLoc introducerLoc)
42224220
: Sink(Sink), Ctx(Ctx), CurrDeclContext(CurrDeclContext),
42234221
ParsedKeywords(ParsedKeywords), introducerLoc(introducerLoc) {
4224-
Ctx.setLegacySemanticQueriesEnabled();
4225-
42264222
hasFuncIntroducer = isKeywordSpecified("func");
42274223
hasVarIntroducer = isKeywordSpecified("var") ||
42284224
isKeywordSpecified("let");

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4420,7 +4420,6 @@ getMemberDecls(InterestedMemberKind Kind) {
44204420
ResolvedMemberResult
44214421
swift::resolveValueMember(DeclContext &DC, Type BaseTy, DeclName Name) {
44224422
ResolvedMemberResult Result;
4423-
assert(DC.getASTContext().areLegacySemanticQueriesEnabled());
44244423
ConstraintSystem CS(&DC, None);
44254424

44264425
// Look up all members of BaseTy with the given Name.

lib/Sema/DebuggerTestingTransform.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ class DebuggerTestingTransform : public ASTWalker {
243243
// TODO: typeCheckExpression() seems to assign types to everything here,
244244
// but may not be sufficient in some cases.
245245
Expr *FinalExpr = ClosureCall;
246-
Ctx.setLegacySemanticQueriesEnabled();
247246
if (!TypeChecker::typeCheckExpression(FinalExpr, getCurrentDeclContext()))
248247
llvm::report_fatal_error("Could not type-check instrumentation");
249248

lib/Sema/IDETypeCheckingRequests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ static bool isExtensionAppliedInternal(const DeclContext *DC, Type BaseTy,
5656
if (!ED->isConstrainedExtension())
5757
return true;
5858

59-
DC->getASTContext().setLegacySemanticQueriesEnabled();
6059
GenericSignature genericSig = ED->getGenericSignature();
6160
SubstitutionMap substMap = BaseTy->getContextSubstitutionMap(
6261
DC->getParentModule(), ED->getExtendedNominal());

lib/Sema/TypeCheckPropertyWrapper.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -497,19 +497,16 @@ AttachedPropertyWrapperTypeRequest::evaluate(Evaluator &evaluator,
497497
if (!customAttr)
498498
return Type();
499499

500-
ASTContext &ctx = var->getASTContext();
501-
if (!ctx.areLegacySemanticQueriesEnabled())
502-
return nullptr;
503-
504500
auto resolution =
505501
TypeResolution::forContextual(var->getDeclContext());
506502
TypeResolutionOptions options(TypeResolverContext::PatternBindingDecl);
507503
options |= TypeResolutionFlags::AllowUnboundGenerics;
508504

509505
if (TypeChecker::validateType(var->getASTContext(),
510506
customAttr->getTypeLoc(),
511-
resolution, options))
512-
return ErrorType::get(ctx);
507+
resolution, options)) {
508+
return ErrorType::get(var->getASTContext());
509+
}
513510

514511
return customAttr->getTypeLoc().getType();
515512
}
@@ -533,10 +530,6 @@ PropertyWrapperBackingPropertyTypeRequest::evaluate(
533530
if (!binding)
534531
return Type();
535532

536-
ASTContext &ctx = var->getASTContext();
537-
if (!ctx.areLegacySemanticQueriesEnabled())
538-
return Type();
539-
540533
// If there's an initializer of some sort, checking it will determine the
541534
// property wrapper type.
542535
unsigned index = binding->getPatternEntryIndexForVarDecl(var);
@@ -546,6 +539,7 @@ PropertyWrapperBackingPropertyTypeRequest::evaluate(
546539
if (!binding->isInitializerChecked(index))
547540
TypeChecker::typeCheckPatternBinding(binding, index);
548541

542+
ASTContext &ctx = var->getASTContext();
549543
Type type = ctx.getSideCachedPropertyWrapperBackingPropertyType(var);
550544
assert(type || ctx.Diags.hadAnyError());
551545
return type;

lib/Sema/TypeChecker.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,6 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval, SourceFile *SF) const {
336336

337337
BufferIndirectlyCausingDiagnosticRAII cpr(*SF);
338338

339-
// Make sure we have a type checker.
340-
Ctx.setLegacySemanticQueriesEnabled();
341-
342339
// Make sure that name binding has been completed before doing any type
343340
// checking.
344341
performNameBinding(*SF);
@@ -528,7 +525,6 @@ bool swift::performTypeLocChecking(ASTContext &Ctx, TypeLoc &T,
528525
Optional<DiagnosticSuppression> suppression;
529526
if (!ProduceDiagnostics)
530527
suppression.emplace(Ctx.Diags);
531-
assert(Ctx.areLegacySemanticQueriesEnabled());
532528
return TypeChecker::validateType(Ctx, T, resolution, options);
533529
}
534530

@@ -565,7 +561,6 @@ void swift::typeCheckPatternBinding(PatternBindingDecl *PBD,
565561

566562
auto &Ctx = PBD->getASTContext();
567563
DiagnosticSuppression suppression(Ctx.Diags);
568-
Ctx.setLegacySemanticQueriesEnabled();
569564
(void)evaluateOrDefault(
570565
Ctx.evaluator, PatternBindingEntryRequest{PBD, bindingIndex}, nullptr);
571566
TypeChecker::typeCheckPatternBinding(PBD, bindingIndex);
@@ -620,7 +615,6 @@ Optional<Type> swift::getTypeOfCompletionContextExpr(
620615
Expr *&parsedExpr,
621616
ConcreteDeclRef &referencedDecl) {
622617
DiagnosticSuppression suppression(Ctx.Diags);
623-
Ctx.setLegacySemanticQueriesEnabled();
624618

625619
// Try to solve for the actual type of the expression.
626620
return ::getTypeOfCompletionContextExpr(DC, kind, parsedExpr,
@@ -635,15 +629,13 @@ swift::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
635629
ConcreteDeclRef &referencedDecl) {
636630
auto &ctx = DC->getASTContext();
637631
DiagnosticSuppression suppression(ctx.Diags);
638-
ctx.setLegacySemanticQueriesEnabled();
639632
return TypeChecker::getTypeOfCompletionOperator(DC, LHS, opName, refKind,
640633
referencedDecl);
641634
}
642635

643636
bool swift::typeCheckExpression(DeclContext *DC, Expr *&parsedExpr) {
644637
auto &ctx = DC->getASTContext();
645638
DiagnosticSuppression suppression(ctx.Diags);
646-
ctx.setLegacySemanticQueriesEnabled();
647639
auto resultTy = TypeChecker::typeCheckExpression(parsedExpr, DC, TypeLoc(),
648640
CTP_Unused);
649641
return !resultTy;
@@ -653,15 +645,12 @@ bool swift::typeCheckAbstractFunctionBodyUntil(AbstractFunctionDecl *AFD,
653645
SourceLoc EndTypeCheckLoc) {
654646
auto &Ctx = AFD->getASTContext();
655647
DiagnosticSuppression suppression(Ctx.Diags);
656-
657-
Ctx.setLegacySemanticQueriesEnabled();
658648
return !TypeChecker::typeCheckAbstractFunctionBodyUntil(AFD, EndTypeCheckLoc);
659649
}
660650

661651
bool swift::typeCheckTopLevelCodeDecl(TopLevelCodeDecl *TLCD) {
662652
auto &Ctx = static_cast<Decl *>(TLCD)->getASTContext();
663653
DiagnosticSuppression suppression(Ctx.Diags);
664-
Ctx.setLegacySemanticQueriesEnabled();
665654
TypeChecker::typeCheckTopLevelCodeDecl(TLCD);
666655
return true;
667656
}

0 commit comments

Comments
 (0)