Skip to content

Commit ed18f47

Browse files
committed
Port getInterfaceType() patterns in libAST
1 parent 8d9629e commit ed18f47

File tree

6 files changed

+12
-37
lines changed

6 files changed

+12
-37
lines changed

lib/AST/ASTContext.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,8 @@ static FuncDecl *findLibraryIntrinsic(const ASTContext &ctx,
922922
ctx.lookupInSwiftModule(name, results);
923923
if (results.size() == 1) {
924924
if (auto FD = dyn_cast<FuncDecl>(results.front())) {
925-
if (auto *resolver = ctx.getLazyResolver())
926-
resolver->resolveDeclSignature(FD);
925+
// FIXME(InterfaceTypeRequest): Remove this.
926+
(void)FD->getInterfaceType();
927927
return FD;
928928
}
929929
}
@@ -987,9 +987,6 @@ lookupOperatorFunc(const ASTContext &ctx, StringRef oper, Type contextType,
987987
if (!contextTy->isEqual(contextType)) continue;
988988
}
989989

990-
if (auto resolver = ctx.getLazyResolver())
991-
resolver->resolveDeclSignature(fnDecl);
992-
993990
auto *funcTy = getIntrinsicCandidateType(fnDecl, /*allowTypeMembers=*/true);
994991
if (!funcTy)
995992
continue;
@@ -3969,8 +3966,6 @@ static NominalTypeDecl *findUnderlyingTypeInModule(ASTContext &ctx,
39693966

39703967
// Look through typealiases.
39713968
if (auto typealias = dyn_cast<TypeAliasDecl>(result)) {
3972-
if (auto resolver = ctx.getLazyResolver())
3973-
resolver->resolveDeclSignature(typealias);
39743969
return typealias->getDeclaredInterfaceType()->getAnyNominal();
39753970
}
39763971
}

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,13 +2343,7 @@ CanType ASTMangler::getDeclTypeForMangling(
23432343
parentGenericSig = nullptr;
23442344

23452345
auto &C = decl->getASTContext();
2346-
if (!decl->hasInterfaceType() && !decl->getDeclContext()->isLocalContext()) {
2347-
if (auto *resolver = C.getLazyResolver()) {
2348-
resolver->resolveDeclSignature(const_cast<ValueDecl *>(decl));
2349-
}
2350-
}
2351-
2352-
if (!decl->hasInterfaceType() || decl->getInterfaceType()->is<ErrorType>()) {
2346+
if (!decl->getInterfaceType() || decl->getInterfaceType()->is<ErrorType>()) {
23532347
if (isa<AbstractFunctionDecl>(decl))
23542348
return CanFunctionType::get({AnyFunctionType::Param(C.TheErrorType)},
23552349
C.TheErrorType);

lib/AST/Decl.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6555,17 +6555,6 @@ static bool requiresNewVTableEntry(const AbstractFunctionDecl *decl) {
65556555
if (decl->isEffectiveLinkageMoreVisibleThan(base))
65566556
return true;
65576557

6558-
// FIXME: Remove this once getInterfaceType() has been request-ified.
6559-
if (!decl->hasInterfaceType()) {
6560-
ctx.getLazyResolver()->resolveDeclSignature(
6561-
const_cast<AbstractFunctionDecl *>(decl));
6562-
}
6563-
6564-
if (!base->hasInterfaceType()) {
6565-
ctx.getLazyResolver()->resolveDeclSignature(
6566-
const_cast<AbstractFunctionDecl *>(base));
6567-
}
6568-
65696558
// If the method overrides something, we only need a new entry if the
65706559
// override has a more general AST type. However an abstraction
65716560
// change is OK; we don't want to add a whole new vtable entry just

lib/AST/Module.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,14 +1817,15 @@ SourceFile::lookupOpaqueResultType(StringRef MangledName,
18171817
auto found = ValidatedOpaqueReturnTypes.find(MangledName);
18181818
if (found != ValidatedOpaqueReturnTypes.end())
18191819
return found->second;
1820-
1820+
18211821
// If there are unvalidated decls with opaque types, go through and validate
18221822
// them now.
18231823
if (resolver && !UnvalidatedDeclsWithOpaqueReturnTypes.empty()) {
18241824
while (!UnvalidatedDeclsWithOpaqueReturnTypes.empty()) {
18251825
ValueDecl *decl = *UnvalidatedDeclsWithOpaqueReturnTypes.begin();
18261826
UnvalidatedDeclsWithOpaqueReturnTypes.erase(decl);
1827-
resolver->resolveDeclSignature(decl);
1827+
// FIXME(InterfaceTypeRequest): Remove this.
1828+
(void)decl->getInterfaceType();
18281829
}
18291830

18301831
found = ValidatedOpaqueReturnTypes.find(MangledName);

lib/AST/NameLookup.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ static void recordShadowedDecls(ArrayRef<ValueDecl *> decls,
434434
if (decls.size() < 2)
435435
return;
436436

437-
auto typeResolver = decls[0]->getASTContext().getLazyResolver();
438-
439437
// Categorize all of the declarations based on their overload signatures.
440438
llvm::SmallDenseMap<CanType, llvm::TinyPtrVector<ValueDecl *>> collisions;
441439
llvm::SmallVector<CanType, 2> collisionTypes;
@@ -463,19 +461,16 @@ static void recordShadowedDecls(ArrayRef<ValueDecl *> decls,
463461
CanType signature;
464462

465463
if (!isa<TypeDecl>(decl)) {
466-
// We need an interface type here.
467-
if (typeResolver)
468-
typeResolver->resolveDeclSignature(decl);
469-
470464
// If the decl is currently being validated, this is likely a recursive
471465
// reference and we'll want to skip ahead so as to avoid having its type
472466
// attempt to desugar itself.
473-
if (!decl->hasInterfaceType())
467+
auto ifaceType = decl->getInterfaceType();
468+
if (!ifaceType)
474469
continue;
475470

476471
// FIXME: the canonical type makes a poor signature, because we don't
477472
// canonicalize away default arguments.
478-
signature = decl->getInterfaceType()->getCanonicalType();
473+
signature = ifaceType->getCanonicalType();
479474

480475
// FIXME: The type of a variable or subscript doesn't include
481476
// enough context to distinguish entities from different

lib/AST/USRGeneration.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,12 @@ swift::USRGenerationRequest::evaluate(Evaluator &evaluator,
241241
}
242242
}
243243

244-
if (!D->hasInterfaceType())
244+
auto declIFaceTy = D->getInterfaceType();
245+
if (!declIFaceTy)
245246
return std::string();
246247

247248
// Invalid code.
248-
if (D->getInterfaceType().findIf([](Type t) -> bool {
249+
if (declIFaceTy.findIf([](Type t) -> bool {
249250
return t->is<ModuleType>();
250251
}))
251252
return std::string();

0 commit comments

Comments
 (0)