mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Port getInterfaceType() patterns in libAST
This commit is contained in:
@@ -922,8 +922,8 @@ static FuncDecl *findLibraryIntrinsic(const ASTContext &ctx,
|
||||
ctx.lookupInSwiftModule(name, results);
|
||||
if (results.size() == 1) {
|
||||
if (auto FD = dyn_cast<FuncDecl>(results.front())) {
|
||||
if (auto *resolver = ctx.getLazyResolver())
|
||||
resolver->resolveDeclSignature(FD);
|
||||
// FIXME(InterfaceTypeRequest): Remove this.
|
||||
(void)FD->getInterfaceType();
|
||||
return FD;
|
||||
}
|
||||
}
|
||||
@@ -987,9 +987,6 @@ lookupOperatorFunc(const ASTContext &ctx, StringRef oper, Type contextType,
|
||||
if (!contextTy->isEqual(contextType)) continue;
|
||||
}
|
||||
|
||||
if (auto resolver = ctx.getLazyResolver())
|
||||
resolver->resolveDeclSignature(fnDecl);
|
||||
|
||||
auto *funcTy = getIntrinsicCandidateType(fnDecl, /*allowTypeMembers=*/true);
|
||||
if (!funcTy)
|
||||
continue;
|
||||
@@ -3969,8 +3966,6 @@ static NominalTypeDecl *findUnderlyingTypeInModule(ASTContext &ctx,
|
||||
|
||||
// Look through typealiases.
|
||||
if (auto typealias = dyn_cast<TypeAliasDecl>(result)) {
|
||||
if (auto resolver = ctx.getLazyResolver())
|
||||
resolver->resolveDeclSignature(typealias);
|
||||
return typealias->getDeclaredInterfaceType()->getAnyNominal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2343,13 +2343,7 @@ CanType ASTMangler::getDeclTypeForMangling(
|
||||
parentGenericSig = nullptr;
|
||||
|
||||
auto &C = decl->getASTContext();
|
||||
if (!decl->hasInterfaceType() && !decl->getDeclContext()->isLocalContext()) {
|
||||
if (auto *resolver = C.getLazyResolver()) {
|
||||
resolver->resolveDeclSignature(const_cast<ValueDecl *>(decl));
|
||||
}
|
||||
}
|
||||
|
||||
if (!decl->hasInterfaceType() || decl->getInterfaceType()->is<ErrorType>()) {
|
||||
if (!decl->getInterfaceType() || decl->getInterfaceType()->is<ErrorType>()) {
|
||||
if (isa<AbstractFunctionDecl>(decl))
|
||||
return CanFunctionType::get({AnyFunctionType::Param(C.TheErrorType)},
|
||||
C.TheErrorType);
|
||||
|
||||
@@ -6555,17 +6555,6 @@ static bool requiresNewVTableEntry(const AbstractFunctionDecl *decl) {
|
||||
if (decl->isEffectiveLinkageMoreVisibleThan(base))
|
||||
return true;
|
||||
|
||||
// FIXME: Remove this once getInterfaceType() has been request-ified.
|
||||
if (!decl->hasInterfaceType()) {
|
||||
ctx.getLazyResolver()->resolveDeclSignature(
|
||||
const_cast<AbstractFunctionDecl *>(decl));
|
||||
}
|
||||
|
||||
if (!base->hasInterfaceType()) {
|
||||
ctx.getLazyResolver()->resolveDeclSignature(
|
||||
const_cast<AbstractFunctionDecl *>(base));
|
||||
}
|
||||
|
||||
// If the method overrides something, we only need a new entry if the
|
||||
// override has a more general AST type. However an abstraction
|
||||
// change is OK; we don't want to add a whole new vtable entry just
|
||||
|
||||
@@ -1824,7 +1824,8 @@ SourceFile::lookupOpaqueResultType(StringRef MangledName,
|
||||
while (!UnvalidatedDeclsWithOpaqueReturnTypes.empty()) {
|
||||
ValueDecl *decl = *UnvalidatedDeclsWithOpaqueReturnTypes.begin();
|
||||
UnvalidatedDeclsWithOpaqueReturnTypes.erase(decl);
|
||||
resolver->resolveDeclSignature(decl);
|
||||
// FIXME(InterfaceTypeRequest): Remove this.
|
||||
(void)decl->getInterfaceType();
|
||||
}
|
||||
|
||||
found = ValidatedOpaqueReturnTypes.find(MangledName);
|
||||
|
||||
@@ -434,8 +434,6 @@ static void recordShadowedDecls(ArrayRef<ValueDecl *> decls,
|
||||
if (decls.size() < 2)
|
||||
return;
|
||||
|
||||
auto typeResolver = decls[0]->getASTContext().getLazyResolver();
|
||||
|
||||
// Categorize all of the declarations based on their overload signatures.
|
||||
llvm::SmallDenseMap<CanType, llvm::TinyPtrVector<ValueDecl *>> collisions;
|
||||
llvm::SmallVector<CanType, 2> collisionTypes;
|
||||
@@ -463,19 +461,16 @@ static void recordShadowedDecls(ArrayRef<ValueDecl *> decls,
|
||||
CanType signature;
|
||||
|
||||
if (!isa<TypeDecl>(decl)) {
|
||||
// We need an interface type here.
|
||||
if (typeResolver)
|
||||
typeResolver->resolveDeclSignature(decl);
|
||||
|
||||
// If the decl is currently being validated, this is likely a recursive
|
||||
// reference and we'll want to skip ahead so as to avoid having its type
|
||||
// attempt to desugar itself.
|
||||
if (!decl->hasInterfaceType())
|
||||
auto ifaceType = decl->getInterfaceType();
|
||||
if (!ifaceType)
|
||||
continue;
|
||||
|
||||
// FIXME: the canonical type makes a poor signature, because we don't
|
||||
// canonicalize away default arguments.
|
||||
signature = decl->getInterfaceType()->getCanonicalType();
|
||||
signature = ifaceType->getCanonicalType();
|
||||
|
||||
// FIXME: The type of a variable or subscript doesn't include
|
||||
// enough context to distinguish entities from different
|
||||
|
||||
@@ -241,11 +241,12 @@ swift::USRGenerationRequest::evaluate(Evaluator &evaluator,
|
||||
}
|
||||
}
|
||||
|
||||
if (!D->hasInterfaceType())
|
||||
auto declIFaceTy = D->getInterfaceType();
|
||||
if (!declIFaceTy)
|
||||
return std::string();
|
||||
|
||||
// Invalid code.
|
||||
if (D->getInterfaceType().findIf([](Type t) -> bool {
|
||||
if (declIFaceTy.findIf([](Type t) -> bool {
|
||||
return t->is<ModuleType>();
|
||||
}))
|
||||
return std::string();
|
||||
|
||||
Reference in New Issue
Block a user