Skip to content

Commit 69a99c5

Browse files
committed
---
yaml --- r: 334847 b: refs/heads/rxwei-patch-1 c: 97602a9 h: refs/heads/master i: 334845: f9f0a3f 334843: 1a9abee 334839: 75679ad 334831: 9e2abff 334815: aa2365b 334783: c53bc02 334719: ca1d823 334591: b522177 334335: 853ee54 333823: 8025994
1 parent 7ead8ed commit 69a99c5

File tree

2 files changed

+51
-32
lines changed

2 files changed

+51
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: ca025ab8cf347de88baa9c6aa706ff3e14b22e50
1018+
refs/heads/rxwei-patch-1: 97602a9829eccb0c25ccee9abfa31eff541aae3d
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/lib/AST/NameLookup.cpp

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,8 +1401,23 @@ namespace {
14011401
DebugClient->lookupOverrides(Name.getBaseName(), dcAndIsCascadingUse.first, Loc,
14021402
isOriginallyTypeLookup, Results))
14031403
return;
1404-
1405-
finishLookupRENAME(dcAndIsCascadingUse.first, dcAndIsCascadingUse.second);
1404+
1405+
recordDependencyOnTopLevelName(dcAndIsCascadingUse.first,
1406+
Name,
1407+
dcAndIsCascadingUse.second);
1408+
addPrivateImports(dcAndIsCascadingUse.first);
1409+
if (addNamesKnownToDebugClient(dcAndIsCascadingUse.first))
1410+
return;
1411+
// If we still haven't found anything, but we do have some
1412+
// declarations that are "unavailable in the current Swift", drop
1413+
// those in.
1414+
if (addUnavailableInnerResults())
1415+
return;
1416+
if (lookForAModuleWithTheGivenName(dcAndIsCascadingUse.first))
1417+
return;
1418+
// Make sure we've recorded the inner-result-boundary.
1419+
(void)isFinishedWithLookupNowThatIsAboutToLookForOuterResults(
1420+
/*noMoreOuterResults=*/true);
14061421
}
14071422

14081423
private:
@@ -2017,25 +2032,30 @@ namespace {
20172032

20182033
return isFinishedWithLookupNowThatIsAboutToLookForOuterResults();
20192034
}
2020-
2021-
void finishLookupRENAME(DeclContext *const dc, const bool isCascadingUse) {
2022-
recordLookupOfTopLevelName(dc, Name, isCascadingUse);
2023-
recordedSF = dyn_cast<SourceFile>(dc);
2035+
2036+
void recordDependencyOnTopLevelName(DeclContext *topLevelContext,
2037+
DeclName name,
2038+
bool isCascadingUse) {
2039+
recordLookupOfTopLevelName(topLevelContext, Name, isCascadingUse);
2040+
recordedSF = dyn_cast<SourceFile>(topLevelContext);
20242041
recordedName = Name;
20252042
recordedIsCascadingUse = isCascadingUse;
2026-
2043+
}
2044+
2045+
void addPrivateImports(DeclContext *const dc) {
20272046
// Add private imports to the extra search list.
20282047
SmallVector<ModuleDecl::ImportedModule, 8> extraImports;
20292048
if (auto FU = dyn_cast<FileUnit>(dc))
20302049
FU->getImportedModules(extraImports, ModuleDecl::ImportFilter::Private);
20312050

20322051
using namespace namelookup;
20332052
SmallVector<ValueDecl *, 8> CurModuleResults;
2034-
auto resolutionKind = isOriginallyTypeLookup ? ResolutionKind::TypesOnly
2053+
auto resolutionKind = isOriginallyTypeLookup
2054+
? ResolutionKind::TypesOnly
20352055
: ResolutionKind::Overloadable;
20362056
lookupInModule(&M, {}, Name, CurModuleResults, NLKind::UnqualifiedLookup,
20372057
resolutionKind, TypeResolver, dc, extraImports);
2038-
2058+
20392059
// Always perform name shadowing for type lookup.
20402060
if (options.contains(Flags::TypeLookup)) {
20412061
removeShadowedDecls(CurModuleResults, &M);
@@ -2046,36 +2066,37 @@ namespace {
20462066

20472067
if (DebugClient)
20482068
filterForDiscriminator(Results, DebugClient);
2049-
2050-
// Now add any names the DebugClient knows about to the lookup.
2069+
}
2070+
2071+
// Return true if done
2072+
bool addNamesKnownToDebugClient(DeclContext *dc) {
20512073
if (Name.isSimpleName() && DebugClient)
20522074
DebugClient->lookupAdditions(Name.getBaseName(), dc, Loc,
20532075
isOriginallyTypeLookup, Results);
2054-
2055-
// If we've found something, we're done.
2056-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults(
2057-
/*noMoreOuterResults=*/true))
2058-
return;
20592076

2060-
// If we still haven't found anything, but we do have some
2061-
// declarations that are "unavailable in the current Swift", drop
2062-
// those in.
2077+
// If we've found something, we're done.
2078+
return isFinishedWithLookupNowThatIsAboutToLookForOuterResults(
2079+
/*noMoreOuterResults=*/true);
2080+
}
2081+
2082+
/// Return true if done
2083+
bool addUnavailableInnerResults() {
20632084
Results = std::move(UnavailableInnerResults);
2064-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults(
2065-
/*noMoreOuterResults=*/true))
2066-
return;
2067-
2085+
return isFinishedWithLookupNowThatIsAboutToLookForOuterResults(
2086+
/*noMoreOuterResults=*/true);
2087+
}
2088+
2089+
bool lookForAModuleWithTheGivenName(DeclContext *const dc) {
2090+
using namespace namelookup;
20682091
if (!Name.isSimpleName())
2069-
return;
2092+
return true;
20702093

20712094
// Look for a module with the given name.
20722095
if (Name.isSimpleName(M.getName())) {
20732096
Results.push_back(LookupResultEntry(&M));
2074-
if (isFinishedWithLookupNowThatIsAboutToLookForOuterResults(
2075-
/*noMoreOuterResults=*/true))
2076-
return;
2097+
return isFinishedWithLookupNowThatIsAboutToLookForOuterResults(
2098+
/*noMoreOuterResults=*/true);
20772099
}
2078-
20792100
ModuleDecl *desiredModule = Ctx.getLoadedModule(Name.getBaseIdentifier());
20802101
if (!desiredModule && Name == Ctx.TheBuiltinModule->getName())
20812102
desiredModule = Ctx.TheBuiltinModule;
@@ -2089,9 +2110,7 @@ namespace {
20892110
return true;
20902111
});
20912112
}
2092-
// Make sure we've recorded the inner-result-boundary.
2093-
(void)isFinishedWithLookupNowThatIsAboutToLookForOuterResults(
2094-
/*noMoreOuterResults=*/true);
2113+
return false;
20952114
}
20962115
};
20972116
} // namespace

0 commit comments

Comments
 (0)