Skip to content

Don't unnecessarily force InterfaceTypeRequest #28040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,13 +923,8 @@ static FuncDecl *findLibraryIntrinsic(const ASTContext &ctx,
StringRef name) {
SmallVector<ValueDecl *, 1> results;
ctx.lookupInSwiftModule(name, results);
if (results.size() == 1) {
if (auto FD = dyn_cast<FuncDecl>(results.front())) {
// FIXME(InterfaceTypeRequest): Remove this.
(void)FD->getInterfaceType();
return FD;
}
}
if (results.size() == 1)
return dyn_cast_or_null<FuncDecl>(results.front());
return nullptr;
}

Expand Down
32 changes: 18 additions & 14 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2520,13 +2520,13 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
[&]{
Printer.printName(decl->getName(), getTypeMemberPrintNameContext(decl));
});
if (decl->hasInterfaceType()) {
if (auto type = decl->getInterfaceType()) {
Printer << ": ";
TypeLoc tyLoc;
if (auto *repr = decl->getTypeReprOrParentPatternTypeRepr())
tyLoc = TypeLoc(repr, decl->getInterfaceType());
tyLoc = TypeLoc(repr, type);
else
tyLoc = TypeLoc::withoutLoc(decl->getInterfaceType());
tyLoc = TypeLoc::withoutLoc(type);

Printer.printDeclResultTypePre(decl, tyLoc);

Expand Down Expand Up @@ -2665,7 +2665,7 @@ void PrintAST::printParameterList(ParameterList *PL,

void PrintAST::printFunctionParameters(AbstractFunctionDecl *AFD) {
auto BodyParams = AFD->getParameters();
auto curTy = AFD->hasInterfaceType() ? AFD->getInterfaceType() : nullptr;
auto curTy = AFD->getInterfaceType();

// Skip over the implicit 'self'.
if (AFD->hasImplicitSelfDecl()) {
Expand Down Expand Up @@ -2872,13 +2872,15 @@ void PrintAST::printEnumElement(EnumElementDecl *elt) {


auto params = ArrayRef<AnyFunctionType::Param>();
if (elt->hasInterfaceType() && !elt->isInvalid()) {
// Walk to the params of the associated values.
// (EnumMetaType) -> (AssocValues) -> Enum
params = elt->getInterfaceType()->castTo<AnyFunctionType>()
->getResult()
->castTo<AnyFunctionType>()
->getParams();
if (auto type = elt->getInterfaceType()) {
if (!elt->isInvalid()) {
// Walk to the params of the associated values.
// (EnumMetaType) -> (AssocValues) -> Enum
params = type->castTo<AnyFunctionType>()
->getResult()
->castTo<AnyFunctionType>()
->getParams();
}
}

// @escaping is not valid in enum element position, even though the
Expand Down Expand Up @@ -2969,9 +2971,11 @@ void PrintAST::visitSubscriptDecl(SubscriptDecl *decl) {
}, [&] { // Parameters
printGenericDeclGenericParams(decl);
auto params = ArrayRef<AnyFunctionType::Param>();
if (decl->hasInterfaceType() && !decl->isInvalid()) {
// Walk to the params of the subscript's indices.
params = decl->getInterfaceType()->castTo<AnyFunctionType>()->getParams();
if (auto type = decl->getInterfaceType()) {
if (!decl->isInvalid()) {
// Walk to the params of the subscript's indices.
params = type->castTo<AnyFunctionType>()->getParams();
}
}
printParameterList(decl->getIndices(), params,
/*isAPINameByDefault*/false);
Expand Down
11 changes: 2 additions & 9 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2969,15 +2969,8 @@ class Verifier : public ASTWalker {
void verifyChecked(AbstractFunctionDecl *AFD) {
PrettyStackTraceDecl debugStack("verifying AbstractFunctionDecl", AFD);

if (!AFD->hasInterfaceType()) {
if (isa<AccessorDecl>(AFD) && AFD->isImplicit())
return;

Out << "All functions except implicit accessors should be "
"validated by now\n";
AFD->dump(Out);
abort();
}
if (!AFD->hasInterfaceType())
return;

// If this function is generic or is within a generic context, it should
// have an interface type.
Expand Down
Loading