Skip to content

Commit dad642c

Browse files
authored
Merge pull request #28040 from slavapestov/dont-force-the-issue
Don't unnecessarily force InterfaceTypeRequest
2 parents 7bb534b + 77e4948 commit dad642c

21 files changed

+83
-251
lines changed

lib/AST/ASTContext.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -923,13 +923,8 @@ static FuncDecl *findLibraryIntrinsic(const ASTContext &ctx,
923923
StringRef name) {
924924
SmallVector<ValueDecl *, 1> results;
925925
ctx.lookupInSwiftModule(name, results);
926-
if (results.size() == 1) {
927-
if (auto FD = dyn_cast<FuncDecl>(results.front())) {
928-
// FIXME(InterfaceTypeRequest): Remove this.
929-
(void)FD->getInterfaceType();
930-
return FD;
931-
}
932-
}
926+
if (results.size() == 1)
927+
return dyn_cast_or_null<FuncDecl>(results.front());
933928
return nullptr;
934929
}
935930

lib/AST/ASTPrinter.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,13 +2520,13 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
25202520
[&]{
25212521
Printer.printName(decl->getName(), getTypeMemberPrintNameContext(decl));
25222522
});
2523-
if (decl->hasInterfaceType()) {
2523+
if (auto type = decl->getInterfaceType()) {
25242524
Printer << ": ";
25252525
TypeLoc tyLoc;
25262526
if (auto *repr = decl->getTypeReprOrParentPatternTypeRepr())
2527-
tyLoc = TypeLoc(repr, decl->getInterfaceType());
2527+
tyLoc = TypeLoc(repr, type);
25282528
else
2529-
tyLoc = TypeLoc::withoutLoc(decl->getInterfaceType());
2529+
tyLoc = TypeLoc::withoutLoc(type);
25302530

25312531
Printer.printDeclResultTypePre(decl, tyLoc);
25322532

@@ -2665,7 +2665,7 @@ void PrintAST::printParameterList(ParameterList *PL,
26652665

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

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

28732873

28742874
auto params = ArrayRef<AnyFunctionType::Param>();
2875-
if (elt->hasInterfaceType() && !elt->isInvalid()) {
2876-
// Walk to the params of the associated values.
2877-
// (EnumMetaType) -> (AssocValues) -> Enum
2878-
params = elt->getInterfaceType()->castTo<AnyFunctionType>()
2879-
->getResult()
2880-
->castTo<AnyFunctionType>()
2881-
->getParams();
2875+
if (auto type = elt->getInterfaceType()) {
2876+
if (!elt->isInvalid()) {
2877+
// Walk to the params of the associated values.
2878+
// (EnumMetaType) -> (AssocValues) -> Enum
2879+
params = type->castTo<AnyFunctionType>()
2880+
->getResult()
2881+
->castTo<AnyFunctionType>()
2882+
->getParams();
2883+
}
28822884
}
28832885

28842886
// @escaping is not valid in enum element position, even though the
@@ -2969,9 +2971,11 @@ void PrintAST::visitSubscriptDecl(SubscriptDecl *decl) {
29692971
}, [&] { // Parameters
29702972
printGenericDeclGenericParams(decl);
29712973
auto params = ArrayRef<AnyFunctionType::Param>();
2972-
if (decl->hasInterfaceType() && !decl->isInvalid()) {
2973-
// Walk to the params of the subscript's indices.
2974-
params = decl->getInterfaceType()->castTo<AnyFunctionType>()->getParams();
2974+
if (auto type = decl->getInterfaceType()) {
2975+
if (!decl->isInvalid()) {
2976+
// Walk to the params of the subscript's indices.
2977+
params = type->castTo<AnyFunctionType>()->getParams();
2978+
}
29752979
}
29762980
printParameterList(decl->getIndices(), params,
29772981
/*isAPINameByDefault*/false);

lib/AST/ASTVerifier.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,15 +2969,8 @@ class Verifier : public ASTWalker {
29692969
void verifyChecked(AbstractFunctionDecl *AFD) {
29702970
PrettyStackTraceDecl debugStack("verifying AbstractFunctionDecl", AFD);
29712971

2972-
if (!AFD->hasInterfaceType()) {
2973-
if (isa<AccessorDecl>(AFD) && AFD->isImplicit())
2974-
return;
2975-
2976-
Out << "All functions except implicit accessors should be "
2977-
"validated by now\n";
2978-
AFD->dump(Out);
2979-
abort();
2980-
}
2972+
if (!AFD->hasInterfaceType())
2973+
return;
29812974

29822975
// If this function is generic or is within a generic context, it should
29832976
// have an interface type.

0 commit comments

Comments
 (0)