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