Skip to content

Commit 934f994

Browse files
committed
Remove DeclContext::isCascadingContextForLookup
1 parent 7bee5ff commit 934f994

File tree

4 files changed

+4
-83
lines changed

4 files changed

+4
-83
lines changed

include/swift/AST/DeclContext.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,6 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
508508
/// FIXME: do this for Protocols, too someday
509509
bool canBeParentOfExtension() const;
510510

511-
/// Returns true if lookups within this context could affect downstream files.
512-
///
513-
/// \param functionsAreNonCascading If true, functions are considered non-
514-
/// cascading contexts. If false, functions are considered non-cascading only
515-
/// if implicitly or explicitly marked private. When concerned only with a
516-
/// function's body, pass true.
517-
bool isCascadingContextForLookup(bool functionsAreNonCascading) const;
518-
519511
/// Look for the set of declarations with the given name within a type,
520512
/// its extensions and, optionally, its supertypes.
521513
///

lib/AST/ASTScopeLookup.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -525,13 +525,9 @@ NullablePtr<const ASTScopeImpl> ASTScopeImpl::ancestorWithDeclSatisfying(
525525

526526
#pragma mark ifUnknownIsCascadingUseAccordingTo
527527

528-
static bool isCascadingUseAccordingTo(const DeclContext *const dc) {
529-
return dc->isCascadingContextForLookup(false);
530-
}
531-
532528
static bool ifUnknownIsCascadingUseAccordingTo(Optional<bool> isCascadingUse,
533529
const DeclContext *const dc) {
534-
return isCascadingUse.getValueOr(isCascadingUseAccordingTo(dc));
530+
return isCascadingUse.getValueOr(false);
535531
}
536532

537533
#pragma mark resolveIsCascadingUseForThisScope
@@ -550,8 +546,7 @@ Optional<bool> GenericParamScope::resolveIsCascadingUseForThisScope(
550546

551547
Optional<bool> AbstractFunctionDeclScope::resolveIsCascadingUseForThisScope(
552548
Optional<bool> isCascadingUse) const {
553-
return decl->isCascadingContextForLookup(false) &&
554-
isCascadingUse.getValueOr(true);
549+
return false;
555550
}
556551

557552
Optional<bool> AbstractFunctionBodyScope::resolveIsCascadingUseForThisScope(

lib/AST/DeclContext.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -445,52 +445,6 @@ bool DeclContext::isInnermostContextGeneric() const {
445445
return false;
446446
}
447447

448-
bool
449-
DeclContext::isCascadingContextForLookup(bool functionsAreNonCascading) const {
450-
// FIXME: This is explicitly checking for attributes in some cases because
451-
// it can be called before access control is computed.
452-
switch (getContextKind()) {
453-
case DeclContextKind::AbstractClosureExpr:
454-
break;
455-
456-
case DeclContextKind::SerializedLocal:
457-
llvm_unreachable("should not perform lookups in deserialized contexts");
458-
459-
case DeclContextKind::Initializer:
460-
// Default arguments still require a type.
461-
if (isa<DefaultArgumentInitializer>(this))
462-
return false;
463-
break;
464-
465-
case DeclContextKind::TopLevelCodeDecl:
466-
// FIXME: Pattern initializers at top-level scope end up here.
467-
return true;
468-
469-
case DeclContextKind::AbstractFunctionDecl:
470-
if (functionsAreNonCascading)
471-
return false;
472-
break;
473-
474-
case DeclContextKind::SubscriptDecl:
475-
break;
476-
477-
case DeclContextKind::EnumElementDecl:
478-
break;
479-
480-
case DeclContextKind::Module:
481-
case DeclContextKind::FileUnit:
482-
return true;
483-
484-
case DeclContextKind::GenericTypeDecl:
485-
break;
486-
487-
case DeclContextKind::ExtensionDecl:
488-
return true;
489-
}
490-
491-
return getParent()->isCascadingContextForLookup(true);
492-
}
493-
494448
unsigned DeclContext::getSyntacticDepth() const {
495449
// Module scope == depth 0.
496450
if (isModuleScopeContext())

lib/AST/NameLookupRequests.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -371,18 +371,7 @@ swift::extractNearestSourceLoc(const LookupConformanceDescriptor &desc) {
371371
evaluator::DependencySource ModuleQualifiedLookupRequest::readDependencySource(
372372
const evaluator::DependencyRecorder &eval) const {
373373
auto *DC = std::get<0>(getStorage());
374-
auto options = std::get<3>(getStorage());
375-
376-
// FIXME(Evaluator Incremental Dependencies): This is an artifact of the
377-
// current scheme and should be removed. There are very few callers that are
378-
// accurately passing the right known dependencies mask.
379-
const bool fromPrivateDC =
380-
DC->isCascadingContextForLookup(/*functionsAreNonCascading=*/false);
381-
382-
auto scope = evaluator::DependencyScope::Cascading;
383-
if (fromPrivateDC)
384-
scope = evaluator::DependencyScope::Private;
385-
return { DC->getParentSourceFile(), scope };
374+
return { DC->getParentSourceFile(), evaluator::DependencyScope::Private };
386375
}
387376

388377
void ModuleQualifiedLookupRequest::writeDependencySink(
@@ -453,18 +442,9 @@ void UnqualifiedLookupRequest::writeDependencySink(
453442
evaluator::DependencySource QualifiedLookupRequest::readDependencySource(
454443
const evaluator::DependencyRecorder &) const {
455444
auto *dc = std::get<0>(getStorage());
456-
auto opts = std::get<3>(getStorage());
457-
// FIXME(Evaluator Incremental Dependencies): This is an artifact of the
458-
// current scheme and should be removed. There are very few callers that are
459-
// accurately passing the right known dependencies mask.
460-
const bool cascades =
461-
dc->isCascadingContextForLookup(/*functionsAreNonCascading*/ false);
462-
auto scope = evaluator::DependencyScope::Cascading;
463-
if (!cascades)
464-
scope = evaluator::DependencyScope::Private;
465445
return {
466446
dyn_cast<SourceFile>(dc->getModuleScopeContext()),
467-
scope
447+
evaluator::DependencyScope::Private
468448
};
469449
}
470450

0 commit comments

Comments
 (0)