@@ -2520,13 +2520,13 @@ void PrintAST::visitVarDecl(VarDecl *decl) {
2520
2520
[&]{
2521
2521
Printer.printName (decl->getName (), getTypeMemberPrintNameContext (decl));
2522
2522
});
2523
- if (decl->hasInterfaceType ()) {
2523
+ if (auto type = decl->getInterfaceType ()) {
2524
2524
Printer << " : " ;
2525
2525
TypeLoc tyLoc;
2526
2526
if (auto *repr = decl->getTypeReprOrParentPatternTypeRepr ())
2527
- tyLoc = TypeLoc (repr, decl-> getInterfaceType () );
2527
+ tyLoc = TypeLoc (repr, type );
2528
2528
else
2529
- tyLoc = TypeLoc::withoutLoc (decl-> getInterfaceType () );
2529
+ tyLoc = TypeLoc::withoutLoc (type );
2530
2530
2531
2531
Printer.printDeclResultTypePre (decl, tyLoc);
2532
2532
@@ -2665,7 +2665,7 @@ void PrintAST::printParameterList(ParameterList *PL,
2665
2665
2666
2666
void PrintAST::printFunctionParameters (AbstractFunctionDecl *AFD) {
2667
2667
auto BodyParams = AFD->getParameters ();
2668
- auto curTy = AFD->hasInterfaceType () ? AFD-> getInterfaceType () : nullptr ;
2668
+ auto curTy = AFD->getInterfaceType ();
2669
2669
2670
2670
// Skip over the implicit 'self'.
2671
2671
if (AFD->hasImplicitSelfDecl ()) {
@@ -2872,13 +2872,15 @@ void PrintAST::printEnumElement(EnumElementDecl *elt) {
2872
2872
2873
2873
2874
2874
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
+ }
2882
2884
}
2883
2885
2884
2886
// @escaping is not valid in enum element position, even though the
@@ -2969,9 +2971,11 @@ void PrintAST::visitSubscriptDecl(SubscriptDecl *decl) {
2969
2971
}, [&] { // Parameters
2970
2972
printGenericDeclGenericParams (decl);
2971
2973
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
+ }
2975
2979
}
2976
2980
printParameterList (decl->getIndices (), params,
2977
2981
/* isAPINameByDefault*/ false );
0 commit comments