@@ -3571,7 +3571,7 @@ bool FailureDiagnosis::diagnoseCalleeResultContextualConversionError() {
3571
3571
// / Return true if the given type conforms to a known protocol type.
3572
3572
static bool conformsToKnownProtocol (Type fromType,
3573
3573
KnownProtocolKind kind,
3574
- ConstraintSystem *CS) {
3574
+ const ConstraintSystem *CS) {
3575
3575
auto proto = CS->TC .getProtocol (SourceLoc (), kind);
3576
3576
if (!proto)
3577
3577
return false ;
@@ -3584,15 +3584,15 @@ static bool conformsToKnownProtocol(Type fromType,
3584
3584
return false ;
3585
3585
}
3586
3586
3587
- static bool isIntegerType (Type fromType, ConstraintSystem *CS) {
3587
+ static bool isIntegerType (Type fromType, const ConstraintSystem *CS) {
3588
3588
return conformsToKnownProtocol (fromType,
3589
3589
KnownProtocolKind::ExpressibleByIntegerLiteral,
3590
3590
CS);
3591
3591
}
3592
3592
3593
3593
// / Return true if the given type conforms to RawRepresentable.
3594
3594
static Type isRawRepresentable (Type fromType,
3595
- ConstraintSystem *CS) {
3595
+ const ConstraintSystem *CS) {
3596
3596
auto rawReprType =
3597
3597
CS->TC .getProtocol (SourceLoc (), KnownProtocolKind::RawRepresentable);
3598
3598
if (!rawReprType)
@@ -3615,7 +3615,7 @@ static Type isRawRepresentable(Type fromType,
3615
3615
// / underlying type conforming to the given known protocol.
3616
3616
static Type isRawRepresentable (Type fromType,
3617
3617
KnownProtocolKind kind,
3618
- ConstraintSystem *CS) {
3618
+ const ConstraintSystem *CS) {
3619
3619
Type rawTy = isRawRepresentable (fromType, CS);
3620
3620
if (!rawTy || !conformsToKnownProtocol (rawTy, kind, CS))
3621
3621
return Type ();
@@ -3646,11 +3646,11 @@ static bool isIntegerToStringIndexConversion(Type fromType, Type toType,
3646
3646
// /
3647
3647
// / This helps migration with SDK changes.
3648
3648
static bool tryRawRepresentableFixIts (InFlightDiagnostic &diag,
3649
- ConstraintSystem *CS,
3649
+ const ConstraintSystem *CS,
3650
3650
Type fromType,
3651
3651
Type toType,
3652
3652
KnownProtocolKind kind,
3653
- Expr *expr) {
3653
+ const Expr *expr) {
3654
3654
// The following fixes apply for optional destination types as well.
3655
3655
bool toTypeIsOptional = !toType->getAnyOptionalObjectType ().isNull ();
3656
3656
toType = toType->lookThroughAllAnyOptionalTypes ();
@@ -3690,7 +3690,8 @@ static bool tryRawRepresentableFixIts(InFlightDiagnostic &diag,
3690
3690
std::string convWrapBefore = toType.getString ();
3691
3691
convWrapBefore += " (rawValue: " ;
3692
3692
std::string convWrapAfter = " )" ;
3693
- if (!CS->TC .isConvertibleTo (fromType, rawTy, CS->DC )) {
3693
+ if (!isa<LiteralExpr>(expr) &&
3694
+ !CS->TC .isConvertibleTo (fromType, rawTy, CS->DC )) {
3694
3695
// Only try to insert a converting construction if the protocol is a
3695
3696
// literal protocol and not some other known protocol.
3696
3697
switch (kind) {
0 commit comments