Skip to content

Commit ee35a4f

Browse files
committed
Remove NameLookupFlags::KnownPrivate
1 parent 259e1a9 commit ee35a4f

11 files changed

+20
-60
lines changed

lib/AST/UnqualifiedLookup.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ namespace {
195195
const bool isOriginallyTypeLookup);
196196

197197
Optional<bool> getInitialIsCascadingUse() const {
198-
return options.contains(Flags::KnownPrivate) ? Optional<bool>(false)
199-
: None;
198+
return Optional<bool>(false);
200199
}
201200

202201
void findResultsAndSaveUnavailables(

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6693,8 +6693,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
66936693
// Ignore access control so we get candidates that might have been missed
66946694
// before.
66956695
lookupOptions |= NameLookupFlags::IgnoreAccessControl;
6696-
// This is only used for diagnostics, so always use KnownPrivate.
6697-
lookupOptions |= NameLookupFlags::KnownPrivate;
66986696

66996697
auto lookup =
67006698
TypeChecker::lookupMember(DC, instanceTy, memberName, lookupOptions);

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,7 @@ LookupResult &ConstraintSystem::lookupMember(Type base, DeclNameRef name) {
247247
if (result) return *result;
248248

249249
// Lookup the member.
250-
NameLookupOptions lookupOptions = defaultMemberLookupOptions;
251-
if (isa<AbstractFunctionDecl>(DC))
252-
lookupOptions |= NameLookupFlags::KnownPrivate;
253-
254-
result = TypeChecker::lookupMember(DC, base, name, lookupOptions);
250+
result = TypeChecker::lookupMember(DC, base, name, defaultMemberLookupOptions);
255251

256252
// If we aren't performing dynamic lookup, we're done.
257253
if (!*result || !base->isAnyObject())

lib/Sema/MiscDiagnostics.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,8 +3458,7 @@ class ObjCSelectorWalker : public ASTWalker {
34583458
auto nominal = method->getDeclContext()->getSelfNominalTypeDecl();
34593459
auto result = TypeChecker::lookupMember(
34603460
const_cast<DeclContext *>(DC), nominal->getDeclaredInterfaceType(),
3461-
DeclNameRef(lookupName),
3462-
(defaultMemberLookupOptions | NameLookupFlags::KnownPrivate));
3461+
DeclNameRef(lookupName), defaultMemberLookupOptions);
34633462

34643463
// If we didn't find multiple methods, there is no ambiguity.
34653464
if (result.size() < 2) return false;

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,11 @@ static bool diagnoseOperatorJuxtaposition(UnresolvedDeclRefExpr *UDRE,
341341

342342
// Perform name lookup for the first and second pieces. If either fail to
343343
// be found, then it isn't a valid split.
344-
NameLookupOptions LookupOptions = defaultUnqualifiedLookupOptions;
345-
// This is only used for diagnostics, so always use KnownPrivate.
346-
LookupOptions |= NameLookupFlags::KnownPrivate;
347344
auto startLookup = TypeChecker::lookupUnqualified(
348-
DC, startName, UDRE->getLoc(), LookupOptions);
345+
DC, startName, UDRE->getLoc(), defaultUnqualifiedLookupOptions);
349346
if (!startLookup) continue;
350347
auto endLookup = TypeChecker::lookupUnqualified(DC, endName, UDRE->getLoc(),
351-
LookupOptions);
348+
defaultUnqualifiedLookupOptions);
352349
if (!endLookup) continue;
353350

354351
// If the overall operator is a binary one, then we're looking at
@@ -536,9 +533,6 @@ Expr *TypeChecker::resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE,
536533

537534
// Perform standard value name lookup.
538535
NameLookupOptions lookupOptions = defaultUnqualifiedLookupOptions;
539-
if (isa<AbstractFunctionDecl>(DC))
540-
lookupOptions |= NameLookupFlags::KnownPrivate;
541-
542536
// TODO: Include all of the possible members to give a solver a
543537
// chance to diagnose name shadowing which requires explicit
544538
// name/module qualifier to access top-level name.
@@ -562,7 +556,6 @@ Expr *TypeChecker::resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE,
562556

563557
// Try ignoring access control.
564558
NameLookupOptions relookupOptions = lookupOptions;
565-
relookupOptions |= NameLookupFlags::KnownPrivate;
566559
relookupOptions |= NameLookupFlags::IgnoreAccessControl;
567560
auto inaccessibleResults =
568561
TypeChecker::lookupUnqualified(DC, Name, Loc, relookupOptions);
@@ -1424,14 +1417,10 @@ TypeExpr *PreCheckExpression::simplifyNestedTypeExpr(UnresolvedDotExpr *UDE) {
14241417
// and not a TypeExpr.
14251418
if (auto *DRE = dyn_cast<DeclRefExpr>(UDE->getBase())) {
14261419
if (auto *TD = dyn_cast<TypeDecl>(DRE->getDecl())) {
1427-
auto lookupOptions = defaultMemberLookupOptions;
1428-
if (isa<AbstractFunctionDecl>(DC) ||
1429-
isa<AbstractClosureExpr>(DC))
1430-
lookupOptions |= NameLookupFlags::KnownPrivate;
1431-
14321420
// See if the type has a member type with this name.
14331421
auto Result = TypeChecker::lookupMemberType(
1434-
DC, TD->getDeclaredInterfaceType(), Name, lookupOptions);
1422+
DC, TD->getDeclaredInterfaceType(), Name,
1423+
defaultMemberLookupOptions);
14351424

14361425
// If there is no nested type with this name, we have a lookup of
14371426
// a non-type member, so leave the expression as-is.
@@ -1484,14 +1473,10 @@ TypeExpr *PreCheckExpression::simplifyNestedTypeExpr(UnresolvedDotExpr *UDE) {
14841473
const auto BaseTy = resolution.resolveType(InnerTypeRepr);
14851474

14861475
if (BaseTy->mayHaveMembers()) {
1487-
auto lookupOptions = defaultMemberLookupOptions;
1488-
if (isa<AbstractFunctionDecl>(DC) ||
1489-
isa<AbstractClosureExpr>(DC))
1490-
lookupOptions |= NameLookupFlags::KnownPrivate;
1491-
14921476
// See if there is a member type with this name.
14931477
auto Result =
1494-
TypeChecker::lookupMemberType(DC, BaseTy, Name, lookupOptions);
1478+
TypeChecker::lookupMemberType(DC, BaseTy, Name,
1479+
defaultMemberLookupOptions);
14951480

14961481
// If there is no nested type with this name, we have a lookup of
14971482
// a non-type member, so leave the expression as-is.
@@ -2466,12 +2451,10 @@ bool TypeChecker::typeCheckExprPattern(ExprPattern *EP, DeclContext *DC,
24662451
EP->setMatchVar(matchVar);
24672452

24682453
// Find '~=' operators for the match.
2469-
auto lookupOptions = defaultUnqualifiedLookupOptions;
2470-
lookupOptions |= NameLookupFlags::KnownPrivate;
24712454
auto matchLookup =
24722455
lookupUnqualified(DC->getModuleScopeContext(),
24732456
DeclNameRef(Context.Id_MatchOperator),
2474-
SourceLoc(), lookupOptions);
2457+
SourceLoc(), defaultUnqualifiedLookupOptions);
24752458
auto &diags = DC->getASTContext().Diags;
24762459
if (!matchLookup) {
24772460
diags.diagnose(EP->getLoc(), diag::no_match_operator);
@@ -3884,8 +3867,6 @@ IsCallableNominalTypeRequest::evaluate(Evaluator &evaluator, CanType ty,
38843867
DeclContext *dc) const {
38853868
auto options = defaultMemberLookupOptions;
38863869
options |= NameLookupFlags::IgnoreAccessControl;
3887-
if (isa<AbstractFunctionDecl>(dc))
3888-
options |= NameLookupFlags::KnownPrivate;
38893870

38903871
// Look for a callAsFunction method.
38913872
auto &ctx = ty->getASTContext();

lib/Sema/TypeCheckExpr.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,13 +617,10 @@ Expr *TypeChecker::buildRefExpr(ArrayRef<ValueDecl *> Decls,
617617
static Type lookupDefaultLiteralType(const DeclContext *dc,
618618
StringRef name) {
619619
auto &ctx = dc->getASTContext();
620-
auto lookupOptions = defaultUnqualifiedLookupOptions;
621-
if (isa<AbstractFunctionDecl>(dc))
622-
lookupOptions |= NameLookupFlags::KnownPrivate;
623620
DeclNameRef nameRef(ctx.getIdentifier(name));
624621
auto lookup = TypeChecker::lookupUnqualified(dc->getModuleScopeContext(),
625622
nameRef, SourceLoc(),
626-
lookupOptions);
623+
defaultUnqualifiedLookupOptions);
627624
TypeDecl *TD = lookup.getSingleTypeResult();
628625
if (!TD)
629626
return Type();

lib/Sema/TypeCheckPattern.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ lookupUnqualifiedEnumMemberElement(DeclContext *DC, DeclNameRef name,
119119
// FIXME: We should probably pay attention to argument labels someday.
120120
name = name.withoutArgumentLabels();
121121

122-
auto lookupOptions = defaultUnqualifiedLookupOptions;
123-
lookupOptions |= NameLookupFlags::KnownPrivate;
124122
auto lookup =
125-
TypeChecker::lookupUnqualified(DC, name, UseLoc, lookupOptions);
123+
TypeChecker::lookupUnqualified(DC, name, UseLoc,
124+
defaultUnqualifiedLookupOptions);
126125
return filterForEnumElement(DC, UseLoc,
127126
/*unqualifiedLookup=*/true, lookup);
128127
}

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,12 +1164,9 @@ WitnessChecker::lookupValueWitnesses(ValueDecl *req, bool *ignoringNames) {
11641164

11651165
if (req->isOperator()) {
11661166
// Operator lookup is always global.
1167-
auto lookupOptions = defaultUnqualifiedLookupOptions;
1168-
if (!DC->isCascadingContextForLookup(false))
1169-
lookupOptions |= NameLookupFlags::KnownPrivate;
11701167
auto lookup = TypeChecker::lookupUnqualified(DC->getModuleScopeContext(),
11711168
reqBaseName, SourceLoc(),
1172-
lookupOptions);
1169+
defaultUnqualifiedLookupOptions);
11731170
for (auto candidate : lookup) {
11741171
auto decl = candidate.getValueDecl();
11751172
if (swift::isMemberOperator(cast<FuncDecl>(decl), Adoptee)) {
@@ -1249,10 +1246,9 @@ bool WitnessChecker::findBestWitness(
12491246
if (!overlay)
12501247
continue;
12511248

1252-
auto lookupOptions = defaultUnqualifiedLookupOptions;
1253-
lookupOptions |= NameLookupFlags::KnownPrivate;
12541249
auto lookup = TypeChecker::lookupUnqualified(
1255-
overlay, requirement->createNameRef(), SourceLoc(), lookupOptions);
1250+
overlay, requirement->createNameRef(), SourceLoc(),
1251+
defaultUnqualifiedLookupOptions);
12561252
for (auto candidate : lookup)
12571253
witnesses.push_back(candidate.getValueDecl());
12581254
break;

lib/Sema/TypeCheckStmt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ static bool checkSuperInit(ConstructorDecl *fromCtor,
16691669
if (!superclassCtor || !superclassCtor->isDesignatedInit() ||
16701670
superclassCtor == ctor)
16711671
continue;
1672-
1672+
16731673
// Found another designated initializer in the superclass. Don't add the
16741674
// super.init() call.
16751675
return true;
@@ -1684,6 +1684,7 @@ static bool checkSuperInit(ConstructorDecl *fromCtor,
16841684
}
16851685
}
16861686

1687+
16871688
return false;
16881689
}
16891690

lib/Sema/TypeCheckType.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,6 @@ static Type diagnoseUnknownType(TypeResolution resolution,
11111111

11121112
// Try ignoring access control.
11131113
NameLookupOptions relookupOptions = lookupOptions;
1114-
relookupOptions |= NameLookupFlags::KnownPrivate;
11151114
relookupOptions |= NameLookupFlags::IgnoreAccessControl;
11161115
auto inaccessibleResults =
11171116
TypeChecker::lookupUnqualifiedType(dc, comp->getNameRef(),
@@ -1177,7 +1176,6 @@ static Type diagnoseUnknownType(TypeResolution resolution,
11771176

11781177
// Try ignoring access control.
11791178
NameLookupOptions relookupOptions = lookupOptions;
1180-
relookupOptions |= NameLookupFlags::KnownPrivate;
11811179
relookupOptions |= NameLookupFlags::IgnoreAccessControl;
11821180
auto inaccessibleMembers =
11831181
TypeChecker::lookupMemberType(dc, parentType, comp->getNameRef(),
@@ -1212,8 +1210,6 @@ static Type diagnoseUnknownType(TypeResolution resolution,
12121210
// identifier not found as a member type vs. not found at all.
12131211
NameLookupOptions memberLookupOptions = lookupOptions;
12141212
memberLookupOptions |= NameLookupFlags::IgnoreAccessControl;
1215-
memberLookupOptions |= NameLookupFlags::KnownPrivate;
1216-
12171213
memberLookup = TypeChecker::lookupMember(dc, parentType,
12181214
comp->getNameRef(),
12191215
memberLookupOptions);

0 commit comments

Comments
 (0)