@@ -3560,7 +3560,7 @@ bool FailureDiagnosis::diagnoseCalleeResultContextualConversionError() {
3560
3560
// / Return true if the given type conforms to a known protocol type.
3561
3561
static bool conformsToKnownProtocol (Type fromType,
3562
3562
KnownProtocolKind kind,
3563
- ConstraintSystem *CS) {
3563
+ const ConstraintSystem *CS) {
3564
3564
auto proto = CS->TC .getProtocol (SourceLoc (), kind);
3565
3565
if (!proto)
3566
3566
return false ;
@@ -3573,15 +3573,15 @@ static bool conformsToKnownProtocol(Type fromType,
3573
3573
return false ;
3574
3574
}
3575
3575
3576
- static bool isIntegerType (Type fromType, ConstraintSystem *CS) {
3576
+ static bool isIntegerType (Type fromType, const ConstraintSystem *CS) {
3577
3577
return conformsToKnownProtocol (fromType,
3578
3578
KnownProtocolKind::ExpressibleByIntegerLiteral,
3579
3579
CS);
3580
3580
}
3581
3581
3582
3582
// / Return true if the given type conforms to RawRepresentable.
3583
3583
static Type isRawRepresentable (Type fromType,
3584
- ConstraintSystem *CS) {
3584
+ const ConstraintSystem *CS) {
3585
3585
auto rawReprType =
3586
3586
CS->TC .getProtocol (SourceLoc (), KnownProtocolKind::RawRepresentable);
3587
3587
if (!rawReprType)
@@ -3604,7 +3604,7 @@ static Type isRawRepresentable(Type fromType,
3604
3604
// / underlying type conforming to the given known protocol.
3605
3605
static Type isRawRepresentable (Type fromType,
3606
3606
KnownProtocolKind kind,
3607
- ConstraintSystem *CS) {
3607
+ const ConstraintSystem *CS) {
3608
3608
Type rawTy = isRawRepresentable (fromType, CS);
3609
3609
if (!rawTy || !conformsToKnownProtocol (rawTy, kind, CS))
3610
3610
return Type ();
@@ -3635,11 +3635,11 @@ static bool isIntegerToStringIndexConversion(Type fromType, Type toType,
3635
3635
// /
3636
3636
// / This helps migration with SDK changes.
3637
3637
static bool tryRawRepresentableFixIts (InFlightDiagnostic &diag,
3638
- ConstraintSystem *CS,
3638
+ const ConstraintSystem *CS,
3639
3639
Type fromType,
3640
3640
Type toType,
3641
3641
KnownProtocolKind kind,
3642
- Expr *expr) {
3642
+ const Expr *expr) {
3643
3643
// The following fixes apply for optional destination types as well.
3644
3644
bool toTypeIsOptional = !toType->getAnyOptionalObjectType ().isNull ();
3645
3645
toType = toType->lookThroughAllAnyOptionalTypes ();
@@ -3679,7 +3679,8 @@ static bool tryRawRepresentableFixIts(InFlightDiagnostic &diag,
3679
3679
std::string convWrapBefore = toType.getString ();
3680
3680
convWrapBefore += " (rawValue: " ;
3681
3681
std::string convWrapAfter = " )" ;
3682
- if (!CS->TC .isConvertibleTo (fromType, rawTy, CS->DC )) {
3682
+ if (!isa<LiteralExpr>(expr) &&
3683
+ !CS->TC .isConvertibleTo (fromType, rawTy, CS->DC )) {
3683
3684
// Only try to insert a converting construction if the protocol is a
3684
3685
// literal protocol and not some other known protocol.
3685
3686
switch (kind) {
0 commit comments