@@ -131,49 +131,25 @@ bool constraints::areConservativelyCompatibleArgumentLabels(
131131 hasCurriedSelf = false ;
132132 } else if (baseType->is <AnyMetatypeType>() && decl->isInstanceMember ()) {
133133 hasCurriedSelf = false ;
134+ } else if (isa<EnumElementDecl>(decl)) {
135+ hasCurriedSelf = false ;
134136 } else {
135137 hasCurriedSelf = true ;
136138 }
137139
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) {
166140 const AnyFunctionType *fTy ;
167141
168142 if (auto fn = dyn_cast<AbstractFunctionDecl>(decl)) {
169143 fTy = fn->getInterfaceType ()->castTo <AnyFunctionType>();
170144 } else if (auto subscript = dyn_cast<SubscriptDecl>(decl)) {
171145 assert (!hasCurriedSelf && " Subscripts never have curried 'self'" );
172146 fTy = subscript->getInterfaceType ()->castTo <AnyFunctionType>();
147+ } else if (auto enumElement = dyn_cast<EnumElementDecl>(decl)) {
148+ fTy = enumElement->getInterfaceType ()->castTo <AnyFunctionType>();
173149 } else {
174150 return true ;
175151 }
176-
152+
177153 SmallVector<AnyFunctionType::Param, 8 > argInfos;
178154 for (auto argLabel : labels) {
179155 argInfos.push_back (AnyFunctionType::Param (Type (), argLabel, {}));
@@ -184,7 +160,7 @@ areConservativelyCompatibleArgumentLabels(ValueDecl *decl,
184160 levelTy = levelTy->getResult ()->getAs <AnyFunctionType>();
185161 assert (levelTy && " Parameter list curry level does not match type" );
186162 }
187-
163+
188164 auto params = levelTy->getParams ();
189165 SmallBitVector defaultMap =
190166 computeDefaultMap (params, decl, hasCurriedSelf);
@@ -198,6 +174,25 @@ areConservativelyCompatibleArgumentLabels(ValueDecl *decl,
198174 listener, unusedParamBindings);
199175}
200176
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+
201196// / Determine the default type-matching options to use when decomposing a
202197// / constraint into smaller constraints.
203198static ConstraintSystem::TypeMatchOptions getDefaultDecompositionOptions (
0 commit comments