@@ -131,49 +131,25 @@ bool constraints::areConservativelyCompatibleArgumentLabels(
131
131
hasCurriedSelf = false ;
132
132
} else if (baseType->is <AnyMetatypeType>() && decl->isInstanceMember ()) {
133
133
hasCurriedSelf = false ;
134
+ } else if (isa<EnumElementDecl>(decl)) {
135
+ hasCurriedSelf = false ;
134
136
} else {
135
137
hasCurriedSelf = true ;
136
138
}
137
139
138
- return areConservativelyCompatibleArgumentLabels (
139
- decl, hasCurriedSelf, labels, hasTrailingClosure);
140
- }
141
-
142
- Expr *constraints::getArgumentLabelTargetExpr (Expr *fn) {
143
- // Dig out the function, looking through, parentheses, ?, and !.
144
- do {
145
- fn = fn->getSemanticsProvidingExpr ();
146
-
147
- if (auto force = dyn_cast<ForceValueExpr>(fn)) {
148
- fn = force->getSubExpr ();
149
- continue ;
150
- }
151
-
152
- if (auto bind = dyn_cast<BindOptionalExpr>(fn)) {
153
- fn = bind->getSubExpr ();
154
- continue ;
155
- }
156
-
157
- return fn;
158
- } while (true );
159
- }
160
-
161
- bool constraints::
162
- areConservativelyCompatibleArgumentLabels (ValueDecl *decl,
163
- bool hasCurriedSelf,
164
- ArrayRef<Identifier> labels,
165
- bool hasTrailingClosure) {
166
140
const AnyFunctionType *fTy ;
167
141
168
142
if (auto fn = dyn_cast<AbstractFunctionDecl>(decl)) {
169
143
fTy = fn->getInterfaceType ()->castTo <AnyFunctionType>();
170
144
} else if (auto subscript = dyn_cast<SubscriptDecl>(decl)) {
171
145
assert (!hasCurriedSelf && " Subscripts never have curried 'self'" );
172
146
fTy = subscript->getInterfaceType ()->castTo <AnyFunctionType>();
147
+ } else if (auto enumElement = dyn_cast<EnumElementDecl>(decl)) {
148
+ fTy = enumElement->getInterfaceType ()->castTo <AnyFunctionType>();
173
149
} else {
174
150
return true ;
175
151
}
176
-
152
+
177
153
SmallVector<AnyFunctionType::Param, 8 > argInfos;
178
154
for (auto argLabel : labels) {
179
155
argInfos.push_back (AnyFunctionType::Param (Type (), argLabel, {}));
@@ -184,7 +160,7 @@ areConservativelyCompatibleArgumentLabels(ValueDecl *decl,
184
160
levelTy = levelTy->getResult ()->getAs <AnyFunctionType>();
185
161
assert (levelTy && " Parameter list curry level does not match type" );
186
162
}
187
-
163
+
188
164
auto params = levelTy->getParams ();
189
165
SmallBitVector defaultMap =
190
166
computeDefaultMap (params, decl, hasCurriedSelf);
@@ -198,6 +174,25 @@ areConservativelyCompatibleArgumentLabels(ValueDecl *decl,
198
174
listener, unusedParamBindings);
199
175
}
200
176
177
+ Expr *constraints::getArgumentLabelTargetExpr (Expr *fn) {
178
+ // Dig out the function, looking through, parentheses, ?, and !.
179
+ do {
180
+ fn = fn->getSemanticsProvidingExpr ();
181
+
182
+ if (auto force = dyn_cast<ForceValueExpr>(fn)) {
183
+ fn = force->getSubExpr ();
184
+ continue ;
185
+ }
186
+
187
+ if (auto bind = dyn_cast<BindOptionalExpr>(fn)) {
188
+ fn = bind->getSubExpr ();
189
+ continue ;
190
+ }
191
+
192
+ return fn;
193
+ } while (true );
194
+ }
195
+
201
196
// / Determine the default type-matching options to use when decomposing a
202
197
// / constraint into smaller constraints.
203
198
static ConstraintSystem::TypeMatchOptions getDefaultDecompositionOptions (
0 commit comments