Skip to content

Commit 89b81a2

Browse files
committed
Fixup calls to TypeChecker::lookupXXX
1 parent 5ab6691 commit 89b81a2

File tree

5 files changed

+32
-36
lines changed

5 files changed

+32
-36
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,8 @@ static void emitFixItForExplicitlyQualifiedReference(
17411741

17421742
void ConstraintSystem::diagnoseDeprecatedConditionalConformanceOuterAccess(
17431743
UnresolvedDotExpr *UDE, ValueDecl *choice) {
1744-
auto result = TC.lookupUnqualified(DC, UDE->getName(), UDE->getLoc());
1744+
auto result =
1745+
TypeChecker::lookupUnqualified(DC, UDE->getName(), UDE->getLoc());
17451746
assert(result && "names can't just disappear");
17461747
// These should all come from the same place.
17471748
auto exampleInner = result.front();
@@ -1940,7 +1941,8 @@ bool FailureDiagnosis::diagnoseImplicitSelfErrors(
19401941
// For each of the parent contexts, let's try to find any candidates
19411942
// which have the same name and the same number of arguments as callee.
19421943
while (context->getParent()) {
1943-
auto result = TC.lookupUnqualified(context, UDE->getName(), UDE->getLoc());
1944+
auto result =
1945+
TypeChecker::lookupUnqualified(context, UDE->getName(), UDE->getLoc());
19441946
context = context->getParent();
19451947

19461948
if (!result || result.empty())

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,11 @@ static bool diagnoseOperatorJuxtaposition(UnresolvedDeclRefExpr *UDRE,
315315
NameLookupOptions LookupOptions = defaultUnqualifiedLookupOptions;
316316
// This is only used for diagnostics, so always use KnownPrivate.
317317
LookupOptions |= NameLookupFlags::KnownPrivate;
318-
auto startLookup = TC.lookupUnqualified(DC, startName, UDRE->getLoc(),
319-
LookupOptions);
318+
auto startLookup = TypeChecker::lookupUnqualified(
319+
DC, startName, UDRE->getLoc(), LookupOptions);
320320
if (!startLookup) continue;
321-
auto endLookup = TC.lookupUnqualified(DC, endName, UDRE->getLoc(),
322-
LookupOptions);
321+
auto endLookup = TypeChecker::lookupUnqualified(DC, endName, UDRE->getLoc(),
322+
LookupOptions);
323323
if (!endLookup) continue;
324324

325325
// If the overall operator is a binary one, then we're looking at
@@ -1404,10 +1404,8 @@ TypeExpr *PreCheckExpression::simplifyNestedTypeExpr(UnresolvedDotExpr *UDE) {
14041404
lookupOptions |= NameLookupFlags::KnownPrivate;
14051405

14061406
// See if the type has a member type with this name.
1407-
auto Result = TC.lookupMemberType(DC,
1408-
TD->getDeclaredInterfaceType(),
1409-
Name,
1410-
lookupOptions);
1407+
auto Result = TypeChecker::lookupMemberType(
1408+
DC, TD->getDeclaredInterfaceType(), Name, lookupOptions);
14111409

14121410
// If there is no nested type with this name, we have a lookup of
14131411
// a non-type member, so leave the expression as-is.
@@ -1462,10 +1460,8 @@ TypeExpr *PreCheckExpression::simplifyNestedTypeExpr(UnresolvedDotExpr *UDE) {
14621460
lookupOptions |= NameLookupFlags::KnownPrivate;
14631461

14641462
// See if there is a member type with this name.
1465-
auto Result = TC.lookupMemberType(DC,
1466-
BaseTy,
1467-
Name,
1468-
lookupOptions);
1463+
auto Result =
1464+
TypeChecker::lookupMemberType(DC, BaseTy, Name, lookupOptions);
14691465

14701466
// If there is no nested type with this name, we have a lookup of
14711467
// a non-type member, so leave the expression as-is.

lib/Sema/TypeCheckPattern.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ lookupUnqualifiedEnumMemberElement(TypeChecker &TC, DeclContext *DC,
117117
Identifier name, SourceLoc UseLoc) {
118118
auto lookupOptions = defaultUnqualifiedLookupOptions;
119119
lookupOptions |= NameLookupFlags::KnownPrivate;
120-
auto lookup = TC.lookupUnqualified(DC, name, SourceLoc(), lookupOptions);
120+
auto lookup =
121+
TypeChecker::lookupUnqualified(DC, name, SourceLoc(), lookupOptions);
121122
return filterForEnumElement(TC, DC, UseLoc,
122123
/*unqualifiedLookup=*/true, lookup);
123124
}

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,17 @@ getTypesToCompare(ValueDecl *reqt, Type reqtType, bool reqtTypeIsIUO,
209209

210210
/// Check that the Objective-C method(s) provided by the witness have
211211
/// the same selectors as those required by the requirement.
212-
static bool checkObjCWitnessSelector(TypeChecker &tc, ValueDecl *req,
213-
ValueDecl *witness) {
212+
static bool checkObjCWitnessSelector(ValueDecl *req, ValueDecl *witness) {
214213
// Simple case: for methods and initializers, check that the selectors match.
215214
if (auto reqFunc = dyn_cast<AbstractFunctionDecl>(req)) {
216215
auto witnessFunc = cast<AbstractFunctionDecl>(witness);
217216
if (reqFunc->getObjCSelector() == witnessFunc->getObjCSelector())
218217
return false;
219218

220219
auto diagInfo = getObjCMethodDiagInfo(witnessFunc);
221-
auto diag = tc.diagnose(witness, diag::objc_witness_selector_mismatch,
222-
diagInfo.first, diagInfo.second,
223-
witnessFunc->getObjCSelector(),
224-
reqFunc->getObjCSelector());
220+
auto diag = witness->diagnose(
221+
diag::objc_witness_selector_mismatch, diagInfo.first, diagInfo.second,
222+
witnessFunc->getObjCSelector(), reqFunc->getObjCSelector());
225223
fixDeclarationObjCName(diag, witnessFunc,
226224
witnessFunc->getObjCSelector(),
227225
reqFunc->getObjCSelector());
@@ -239,15 +237,15 @@ static bool checkObjCWitnessSelector(TypeChecker &tc, ValueDecl *req,
239237
if (auto reqGetter = reqStorage->getParsedAccessor(AccessorKind::Get)) {
240238
auto *witnessGetter =
241239
witnessStorage->getSynthesizedAccessor(AccessorKind::Get);
242-
if (checkObjCWitnessSelector(tc, reqGetter, witnessGetter))
240+
if (checkObjCWitnessSelector(reqGetter, witnessGetter))
243241
return true;
244242
}
245243

246244
// Check the setter.
247245
if (auto reqSetter = reqStorage->getParsedAccessor(AccessorKind::Set)) {
248246
auto *witnessSetter =
249247
witnessStorage->getSynthesizedAccessor(AccessorKind::Set);
250-
if (checkObjCWitnessSelector(tc, reqSetter, witnessSetter))
248+
if (checkObjCWitnessSelector(reqSetter, witnessSetter))
251249
return true;
252250
}
253251

@@ -932,10 +930,9 @@ WitnessChecker::lookupValueWitnesses(ValueDecl *req, bool *ignoringNames) {
932930
auto lookupOptions = defaultUnqualifiedLookupOptions;
933931
if (!DC->isCascadingContextForLookup(false))
934932
lookupOptions |= NameLookupFlags::KnownPrivate;
935-
auto lookup = TC.lookupUnqualified(DC->getModuleScopeContext(),
936-
req->getBaseName(),
937-
SourceLoc(),
938-
lookupOptions);
933+
auto lookup = TypeChecker::lookupUnqualified(DC->getModuleScopeContext(),
934+
req->getBaseName(),
935+
SourceLoc(), lookupOptions);
939936
for (auto candidate : lookup) {
940937
auto decl = candidate.getValueDecl();
941938
if (swift::isMemberOperator(cast<FuncDecl>(decl), Adoptee)) {
@@ -1007,8 +1004,8 @@ bool WitnessChecker::findBestWitness(
10071004

10081005
auto lookupOptions = defaultUnqualifiedLookupOptions;
10091006
lookupOptions |= NameLookupFlags::KnownPrivate;
1010-
auto lookup = TC.lookupUnqualified(overlay, requirement->getBaseName(),
1011-
SourceLoc(), lookupOptions);
1007+
auto lookup = TypeChecker::lookupUnqualified(
1008+
overlay, requirement->getBaseName(), SourceLoc(), lookupOptions);
10121009
for (auto candidate : lookup)
10131010
witnesses.push_back(candidate.getValueDecl());
10141011
break;
@@ -3492,8 +3489,8 @@ ResolveWitnessResult ConformanceChecker::resolveTypeWitnessViaLookup(
34923489
}
34933490

34943491
// Look for a member type with the same name as the associated type.
3495-
auto candidates = TC.lookupMemberType(DC, Adoptee, assocType->getName(),
3496-
NameLookupFlags::ProtocolMembers);
3492+
auto candidates = TypeChecker::lookupMemberType(
3493+
DC, Adoptee, assocType->getName(), NameLookupFlags::ProtocolMembers);
34973494

34983495
// If there aren't any candidates, we're done.
34993496
if (!candidates) {
@@ -3838,7 +3835,7 @@ void ConformanceChecker::resolveValueWitnesses() {
38383835
}
38393836

38403837
// The selectors must coincide.
3841-
if (checkObjCWitnessSelector(TC, requirement, witness)) {
3838+
if (checkObjCWitnessSelector(requirement, witness)) {
38423839
Conformance->setInvalid();
38433840
return;
38443841
}

lib/Sema/TypeCheckREPL.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ struct REPLContext {
4646

4747
{
4848
Identifier Id(Context.getIdentifier("_replPrintLiteralString"));
49-
auto lookup = TC.lookupUnqualified(TC.getStdlibModule(&SF),
50-
Id, SourceLoc());
49+
auto lookup = TypeChecker::lookupUnqualified(TC.getStdlibModule(&SF), Id,
50+
SourceLoc());
5151
if (!lookup)
5252
return true;
5353
for (auto result : lookup)
5454
PrintDecls.push_back(result.getValueDecl());
5555
}
5656
{
5757
Identifier Id(Context.getIdentifier("_replDebugPrintln"));
58-
auto lookup = TC.lookupUnqualified(TC.getStdlibModule(&SF),
59-
Id, SourceLoc());
58+
auto lookup = TypeChecker::lookupUnqualified(TC.getStdlibModule(&SF), Id,
59+
SourceLoc());
6060
if (!lookup)
6161
return true;
6262
for (auto result : lookup)

0 commit comments

Comments
 (0)