@@ -116,43 +116,40 @@ ParameterList *ParameterList::clone(const ASTContext &C,
116
116
return create (C, params);
117
117
}
118
118
119
- // / Return a TupleType or ParenType for this parameter list, written in terms
120
- // / of contextual archetypes.
121
- Type ParameterList::getType (const ASTContext &C) const {
119
+ // / Return a TupleType or ParenType for this parameter list,
120
+ // / based on types provided by a callback.
121
+ Type ParameterList::getType (
122
+ const ASTContext &C, llvm::function_ref<Type(ParamDecl *)> getType) const {
122
123
if (size () == 0 )
123
124
return TupleType::getEmpty (C);
124
-
125
+
125
126
SmallVector<TupleTypeElt, 8 > argumentInfo;
126
-
127
+
127
128
for (auto P : *this ) {
128
- auto type = P-> getType ();
129
-
130
- argumentInfo. emplace_back (
131
- type-> getInOutObjectType (), P->getArgumentName (),
132
- ParameterTypeFlags::fromParameterType (type, P-> isVariadic (), P-> isShared ()) .withInOut (P->isInOut ()));
129
+ auto type = getType (P );
130
+ argumentInfo. emplace_back (type-> getInOutObjectType (), P-> getArgumentName (),
131
+ ParameterTypeFlags::fromParameterType (
132
+ type, P-> isVariadic (), P->isShared ())
133
+ .withInOut (P->isInOut ()));
133
134
}
134
135
135
136
return TupleType::get (argumentInfo, C);
136
137
}
137
138
139
+ // / Return a TupleType or ParenType for this parameter list, written in terms
140
+ // / of contextual archetypes.
141
+ Type ParameterList::getType (const ASTContext &C) const {
142
+ return getType (C, [](ParamDecl *P) { return P->getType (); });
143
+ }
144
+
138
145
// / Return a TupleType or ParenType for this parameter list, written in terms
139
146
// / of interface types.
140
147
Type ParameterList::getInterfaceType (const ASTContext &C) const {
141
- if (size () == 0 )
142
- return TupleType::getEmpty (C);
143
-
144
- SmallVector<TupleTypeElt, 8 > argumentInfo;
145
-
146
- for (auto P : *this ) {
148
+ return getType (C, [](ParamDecl *P) {
147
149
auto type = P->getInterfaceType ();
148
150
assert (!type->hasArchetype ());
149
-
150
- argumentInfo.emplace_back (
151
- type->getInOutObjectType (), P->getArgumentName (),
152
- ParameterTypeFlags::fromParameterType (type, P->isVariadic (), P->isShared ()).withInOut (P->isInOut ()));
153
- }
154
-
155
- return TupleType::get (argumentInfo, C);
151
+ return type;
152
+ });
156
153
}
157
154
158
155
0 commit comments