Skip to content

Commit c8df921

Browse files
committed
---
yaml --- r: 326011 b: refs/heads/master-next c: 08ae9e5 h: refs/heads/master i: 326009: 07bb8cb 326007: 87cd363
1 parent 5598790 commit c8df921

File tree

2 files changed

+1
-135
lines changed

2 files changed

+1
-135
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: e052da7d8886fa0439677852e8f7830b20c2e1da
3-
refs/heads/master-next: 3d242bd110bbc2b75614edd6d201da5954d63c7a
3+
refs/heads/master-next: 08ae9e57cd3de83e783ee3f80237a69c44b82b7c
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/Sema/CSDiag.cpp

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,134 +2713,6 @@ diagnoseSingleCandidateFailures(CalleeCandidateInfo &CCI, Expr *fnExpr,
27132713
.diagnose();
27142714
}
27152715

2716-
namespace {
2717-
enum class RawRepresentableMismatch {
2718-
NotApplicable,
2719-
Convertible,
2720-
ExactMatch
2721-
};
2722-
}
2723-
2724-
static RawRepresentableMismatch
2725-
checkRawRepresentableMismatch(Type fromType, Type toType,
2726-
KnownProtocolKind kind,
2727-
ConstraintSystem &CS) {
2728-
toType = toType->lookThroughAllOptionalTypes();
2729-
fromType = fromType->lookThroughAllOptionalTypes();
2730-
2731-
// First check if this is an attempt to convert from something to
2732-
// raw representable.
2733-
if (conformsToKnownProtocol(CS, fromType, kind)) {
2734-
if (auto rawType = isRawRepresentable(CS, toType, kind)) {
2735-
if (rawType->isEqual(fromType))
2736-
return RawRepresentableMismatch::ExactMatch;
2737-
return RawRepresentableMismatch::Convertible;
2738-
}
2739-
}
2740-
2741-
// Otherwise, it might be an attempt to convert from raw representable
2742-
// to its raw value.
2743-
if (auto rawType = isRawRepresentable(CS, fromType, kind)) {
2744-
if (conformsToKnownProtocol(CS, toType, kind)) {
2745-
if (rawType->isEqual(toType))
2746-
return RawRepresentableMismatch::ExactMatch;
2747-
return RawRepresentableMismatch::Convertible;
2748-
}
2749-
}
2750-
2751-
return RawRepresentableMismatch::NotApplicable;
2752-
}
2753-
2754-
static bool diagnoseRawRepresentableMismatch(CalleeCandidateInfo &CCI,
2755-
Expr *argExpr,
2756-
ArrayRef<Identifier> argLabels) {
2757-
// We are only interested in cases which are
2758-
// unrelated to argument count or label mismatches.
2759-
switch (CCI.closeness) {
2760-
case CC_OneArgumentNearMismatch:
2761-
case CC_OneArgumentMismatch:
2762-
case CC_OneGenericArgumentNearMismatch:
2763-
case CC_OneGenericArgumentMismatch:
2764-
case CC_ArgumentNearMismatch:
2765-
case CC_ArgumentMismatch:
2766-
break;
2767-
2768-
default:
2769-
return false;
2770-
}
2771-
2772-
auto argType = CCI.CS.getType(argExpr);
2773-
if (!argType || argType->hasTypeVariable() || argType->hasUnresolvedType())
2774-
return false;
2775-
2776-
KnownProtocolKind rawRepresentableProtocols[] = {
2777-
KnownProtocolKind::ExpressibleByStringLiteral,
2778-
KnownProtocolKind::ExpressibleByIntegerLiteral};
2779-
2780-
auto &CS = CCI.CS;
2781-
auto arguments = decomposeArgType(argType, argLabels);
2782-
2783-
auto bestMatchKind = RawRepresentableMismatch::NotApplicable;
2784-
const OverloadCandidate *bestMatchCandidate = nullptr;
2785-
KnownProtocolKind bestMatchProtocol;
2786-
size_t bestMatchIndex;
2787-
2788-
for (auto &candidate : CCI.candidates) {
2789-
auto *decl = candidate.getDecl();
2790-
if (!decl)
2791-
continue;
2792-
2793-
if (!candidate.hasParameters())
2794-
continue;
2795-
2796-
auto parameters = candidate.getParameters();
2797-
// FIXME: Default arguments?
2798-
if (parameters.size() != arguments.size())
2799-
continue;
2800-
2801-
for (unsigned i = 0, n = parameters.size(); i != n; ++i) {
2802-
auto paramType = parameters[i].getOldType();
2803-
auto argType = arguments[i].getOldType();
2804-
2805-
for (auto kind : rawRepresentableProtocols) {
2806-
// If trying to convert from raw type to raw representable,
2807-
// or vice versa from raw representable (e.g. enum) to raw type.
2808-
auto matchKind = checkRawRepresentableMismatch(argType, paramType, kind,
2809-
CS);
2810-
if (matchKind > bestMatchKind) {
2811-
bestMatchKind = matchKind;
2812-
bestMatchProtocol = kind;
2813-
bestMatchCandidate = &candidate;
2814-
bestMatchIndex = i;
2815-
}
2816-
}
2817-
}
2818-
}
2819-
2820-
if (bestMatchKind == RawRepresentableMismatch::NotApplicable)
2821-
return false;
2822-
2823-
Expr *expr = argExpr;
2824-
if (auto *tupleArgs = dyn_cast<TupleExpr>(argExpr))
2825-
expr = tupleArgs->getElement(bestMatchIndex);
2826-
2827-
expr = expr->getValueProvidingExpr();
2828-
2829-
auto parameters = bestMatchCandidate->getParameters();
2830-
auto paramType = parameters[bestMatchIndex].getOldType();
2831-
auto singleArgType = arguments[bestMatchIndex].getOldType();
2832-
2833-
auto diag = CS.TC.diagnose(expr->getLoc(),
2834-
diag::cannot_convert_argument_value,
2835-
singleArgType, paramType);
2836-
2837-
ContextualFailure failure(expr, CS, singleArgType, paramType,
2838-
CS.getConstraintLocator(expr));
2839-
2840-
(void)failure.tryRawRepresentableFixIts(diag, bestMatchProtocol);
2841-
return true;
2842-
}
2843-
28442716
// Extract expression for failed argument number
28452717
static Expr *getFailedArgumentExpr(CalleeCandidateInfo CCI, Expr *argExpr) {
28462718
if (auto *TE = dyn_cast<TupleExpr>(argExpr))
@@ -4117,9 +3989,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
41173989
if (isContextualConversionFailure(argTuple))
41183990
return false;
41193991

4120-
if (diagnoseRawRepresentableMismatch(calleeInfo, argExpr, argLabels))
4121-
return true;
4122-
41233992
if (!lhsType->isEqual(rhsType)) {
41243993
auto diag = diagnose(callExpr->getLoc(), diag::cannot_apply_binop_to_args,
41253994
overloadName, lhsType, rhsType);
@@ -4219,9 +4088,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
42194088
if (CS.getType(argExpr)->hasUnresolvedType())
42204089
return false;
42214090

4222-
if (diagnoseRawRepresentableMismatch(calleeInfo, argExpr, argLabels))
4223-
return true;
4224-
42254091
SmallVector<AnyFunctionType::Param, 8> params;
42264092
AnyFunctionType::decomposeInput(CS.getType(argExpr), params);
42274093
auto argString = AnyFunctionType::getParamListAsString(params);

0 commit comments

Comments
 (0)