@@ -166,12 +166,6 @@ bool FailureDiagnostic::conformsToKnownProtocol(
166
166
return constraints::conformsToKnownProtocol (cs, type, protocol);
167
167
}
168
168
169
- Type FailureDiagnostic::isRawRepresentable (Type type,
170
- KnownProtocolKind protocol) const {
171
- auto &cs = getConstraintSystem ();
172
- return constraints::isRawRepresentable (cs, type, protocol);
173
- }
174
-
175
169
Type RequirementFailure::getOwnerType () const {
176
170
auto anchor = getRawAnchor ();
177
171
@@ -2297,12 +2291,6 @@ void ContextualFailure::tryFixIts(InFlightDiagnostic &diagnostic) const {
2297
2291
if (trySequenceSubsequenceFixIts (diagnostic))
2298
2292
return ;
2299
2293
2300
- if (tryRawRepresentableFixIts (
2301
- diagnostic, KnownProtocolKind::ExpressibleByIntegerLiteral) ||
2302
- tryRawRepresentableFixIts (diagnostic,
2303
- KnownProtocolKind::ExpressibleByStringLiteral))
2304
- return ;
2305
-
2306
2294
if (tryIntegerCastFixIts (diagnostic))
2307
2295
return ;
2308
2296
@@ -2532,59 +2520,6 @@ bool ContextualFailure::diagnoseYieldByReferenceMismatch() const {
2532
2520
return true ;
2533
2521
}
2534
2522
2535
- bool ContextualFailure::tryRawRepresentableFixIts (
2536
- InFlightDiagnostic &diagnostic,
2537
- KnownProtocolKind rawRepresentableProtocol) const {
2538
- auto anchor = getAnchor ();
2539
- auto fromType = getFromType ();
2540
- auto toType = getToType ();
2541
-
2542
- // The following fixes apply for optional destination types as well.
2543
- bool toTypeIsOptional = !toType->getOptionalObjectType ().isNull ();
2544
- toType = toType->lookThroughAllOptionalTypes ();
2545
-
2546
- Type fromTypeUnwrapped = fromType->getOptionalObjectType ();
2547
- bool fromTypeIsOptional = !fromTypeUnwrapped.isNull ();
2548
- if (fromTypeIsOptional)
2549
- fromType = fromTypeUnwrapped;
2550
-
2551
- auto fixIt = [&](StringRef convWrapBefore, StringRef convWrapAfter,
2552
- const Expr *expr) {
2553
- SourceRange exprRange = expr->getSourceRange ();
2554
- if (fromTypeIsOptional && toTypeIsOptional) {
2555
- // Use optional's map function to convert conditionally, like so:
2556
- // expr.map{ T(rawValue: $0) }
2557
- bool needsParens = !expr->canAppendPostfixExpression ();
2558
- std::string mapCodeFix;
2559
- if (needsParens) {
2560
- diagnostic.fixItInsert (exprRange.Start , " (" );
2561
- mapCodeFix += " )" ;
2562
- }
2563
- mapCodeFix += " .map { " ;
2564
- mapCodeFix += convWrapBefore;
2565
- mapCodeFix += " $0" ;
2566
- mapCodeFix += convWrapAfter;
2567
- mapCodeFix += " }" ;
2568
- diagnostic.fixItInsertAfter (exprRange.End , mapCodeFix);
2569
- } else if (!fromTypeIsOptional) {
2570
- diagnostic.fixItInsert (exprRange.Start , convWrapBefore);
2571
- diagnostic.fixItInsertAfter (exprRange.End , convWrapAfter);
2572
- }
2573
- };
2574
-
2575
- if (auto rawTy = isRawRepresentable (fromType, rawRepresentableProtocol)) {
2576
- if (conformsToKnownProtocol (toType, rawRepresentableProtocol)) {
2577
- std::string convWrapBefore;
2578
- std::string convWrapAfter = " .rawValue" ;
2579
- if (auto *E = getAsExpr (anchor))
2580
- fixIt (convWrapBefore, convWrapAfter, E);
2581
- return true ;
2582
- }
2583
- }
2584
-
2585
- return false ;
2586
- }
2587
-
2588
2523
bool ContextualFailure::tryIntegerCastFixIts (
2589
2524
InFlightDiagnostic &diagnostic) const {
2590
2525
auto fromType = getFromType ();
0 commit comments