Skip to content

Commit 4cdbba4

Browse files
committed
---
yaml --- r: 347079 b: refs/heads/master c: 21b9aef h: refs/heads/master i: 347077: 1815294 347075: 4231fa3 347071: fc89d8f
1 parent b03888e commit 4cdbba4

File tree

5 files changed

+29
-375
lines changed

5 files changed

+29
-375
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: af7f34e6811aede14377e82c9c0ef36aed828a4b
2+
refs/heads/master: 21b9aefc71aa5fcc11f13fcb45abef747cde4491
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/Sema/CSSimplify.cpp

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
203198
static ConstraintSystem::TypeMatchOptions getDefaultDecompositionOptions(

0 commit comments

Comments
 (0)