Skip to content

Commit 65738ea

Browse files
authored
Merge pull request #18343 from rudkx/function-types
[PrintAsObjC] Replace a couple uses of getInput() with getParams().
2 parents 1f80d21 + ffb74a5 commit 65738ea

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

lib/PrintAsObjC/PrintAsObjC.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -1837,20 +1837,15 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
18371837
/// "(A) -> ((B) -> C)" becomes "C (^ (^)(A))(B)".
18381838
void finishFunctionType(const FunctionType *FT) {
18391839
os << ")(";
1840-
Type paramsTy = FT->getInput();
1841-
if (auto tupleTy = paramsTy->getAs<TupleType>()) {
1842-
if (FT->getParams().empty()) {
1843-
os << "void";
1844-
} else {
1845-
interleave(tupleTy->getElements(),
1846-
[this](TupleTypeElt elt) {
1847-
print(elt.getType(), OTK_None, elt.getName(),
1848-
IsFunctionParam);
1849-
},
1850-
[this] { os << ", "; });
1851-
}
1840+
if (!FT->getParams().empty()) {
1841+
interleave(FT->getParams(),
1842+
[this](const AnyFunctionType::Param &param) {
1843+
print(param.getType(), OTK_None, param.getLabel(),
1844+
IsFunctionParam);
1845+
},
1846+
[this] { os << ", "; });
18521847
} else {
1853-
print(paramsTy, OTK_None, Identifier(), IsFunctionParam);
1848+
os << "void";
18541849
}
18551850
os << ")";
18561851
}
@@ -1993,7 +1988,8 @@ class ReferencedTypeFinder : public TypeVisitor<ReferencedTypeFinder> {
19931988
}
19941989

19951990
void visitAnyFunctionType(AnyFunctionType *fnTy) {
1996-
visit(fnTy->getInput());
1991+
for (auto &param : fnTy->getParams())
1992+
visit(param.getType());
19971993
visit(fnTy->getResult());
19981994
}
19991995

0 commit comments

Comments
 (0)