File tree Expand file tree Collapse file tree 5 files changed +23
-32
lines changed Expand file tree Collapse file tree 5 files changed +23
-32
lines changed Original file line number Diff line number Diff line change @@ -5323,6 +5323,8 @@ class ParamDecl : public VarDecl {
5323
5323
5324
5324
SourceRange getSourceRange () const ;
5325
5325
5326
+ AnyFunctionType::Param toFunctionParam (Type type = Type()) const ;
5327
+
5326
5328
// Implement isa/cast/dyncast/etc.
5327
5329
static bool classof (const Decl *D) {
5328
5330
return D->getKind () == DeclKind::Param;
Original file line number Diff line number Diff line change @@ -127,12 +127,6 @@ class alignas(ParamDecl *) ParameterList final :
127
127
// / based on the interface types of the parameters in this list.
128
128
void getParams (SmallVectorImpl<AnyFunctionType::Param> ¶ms) const ;
129
129
130
- // / Return a list of function parameters for this parameter list,
131
- // / based on types provided by a callback.
132
- void getParams (SmallVectorImpl<AnyFunctionType::Param> ¶ms,
133
- llvm::function_ref<Type (ParamDecl *)> getType) const ;
134
-
135
-
136
130
// / Return the full source range of this parameter.
137
131
SourceRange getSourceRange () const ;
138
132
SourceLoc getStartLoc () const { return getSourceRange ().Start ; }
Original file line number Diff line number Diff line change @@ -5673,6 +5673,21 @@ Type ParamDecl::getVarargBaseTy(Type VarArgT) {
5673
5673
return T;
5674
5674
}
5675
5675
5676
+ AnyFunctionType::Param ParamDecl::toFunctionParam (Type type) const {
5677
+ if (!type)
5678
+ type = getInterfaceType ();
5679
+
5680
+ if (isVariadic ())
5681
+ type = ParamDecl::getVarargBaseTy (type);
5682
+
5683
+ auto label = getArgumentName ();
5684
+ auto flags = ParameterTypeFlags::fromParameterType (type,
5685
+ isVariadic (),
5686
+ isAutoClosure (),
5687
+ getValueOwnership ());
5688
+ return AnyFunctionType::Param (type, label, flags);
5689
+ }
5690
+
5676
5691
void ParamDecl::setDefaultValue (Expr *E) {
5677
5692
if (!DefaultValueAndFlags.getPointer ()) {
5678
5693
if (!E) return ;
Original file line number Diff line number Diff line change @@ -89,29 +89,8 @@ ParameterList *ParameterList::clone(const ASTContext &C,
89
89
90
90
void ParameterList::getParams (
91
91
SmallVectorImpl<AnyFunctionType::Param> ¶ms) const {
92
- getParams (params,
93
- [](ParamDecl *decl) { return decl->getInterfaceType (); });
94
- }
95
-
96
- void ParameterList::getParams (
97
- SmallVectorImpl<AnyFunctionType::Param> ¶ms,
98
- llvm::function_ref<Type(ParamDecl *)> getType) const {
99
- if (size () == 0 )
100
- return ;
101
-
102
- for (auto P : *this ) {
103
- auto type = getType (P);
104
-
105
- if (P->isVariadic ())
106
- type = ParamDecl::getVarargBaseTy (type);
107
-
108
- auto label = P->getArgumentName ();
109
- auto flags = ParameterTypeFlags::fromParameterType (type,
110
- P->isVariadic (),
111
- P->isAutoClosure (),
112
- P->getValueOwnership ());
113
- params.emplace_back (type, label, flags);
114
- }
92
+ for (auto P : *this )
93
+ params.push_back (P->toFunctionParam ());
115
94
}
116
95
117
96
Original file line number Diff line number Diff line change @@ -2036,7 +2036,8 @@ namespace {
2036
2036
SmallVectorImpl<AnyFunctionType::Param> ¶ms) {
2037
2037
auto *paramList = closureExpr->getParameters ();
2038
2038
unsigned i = 0 ;
2039
- paramList->getParams (params, [&](ParamDecl *param) {
2039
+
2040
+ for (auto *param : *paramList) {
2040
2041
auto *locator = CS.getConstraintLocator (
2041
2042
closureExpr, LocatorPathElt::getTupleElement (i++));
2042
2043
Type paramType, internalType;
@@ -2058,8 +2059,8 @@ namespace {
2058
2059
locator);
2059
2060
}
2060
2061
CS.setType (param, internalType);
2061
- return paramType;
2062
- });
2062
+ params. push_back (param-> toFunctionParam ( paramType)) ;
2063
+ }
2063
2064
}
2064
2065
2065
2066
// / Produces a type for the given pattern, filling in any missing
You can’t perform that action at this time.
0 commit comments