@@ -3560,7 +3560,7 @@ bool FailureDiagnosis::diagnoseCalleeResultContextualConversionError() {
35603560// / Return true if the given type conforms to a known protocol type.
35613561static bool conformsToKnownProtocol (Type fromType,
35623562 KnownProtocolKind kind,
3563- ConstraintSystem *CS) {
3563+ const ConstraintSystem *CS) {
35643564 auto proto = CS->TC .getProtocol (SourceLoc (), kind);
35653565 if (!proto)
35663566 return false ;
@@ -3573,15 +3573,15 @@ static bool conformsToKnownProtocol(Type fromType,
35733573 return false ;
35743574}
35753575
3576- static bool isIntegerType (Type fromType, ConstraintSystem *CS) {
3576+ static bool isIntegerType (Type fromType, const ConstraintSystem *CS) {
35773577 return conformsToKnownProtocol (fromType,
35783578 KnownProtocolKind::ExpressibleByIntegerLiteral,
35793579 CS);
35803580}
35813581
35823582// / Return true if the given type conforms to RawRepresentable.
35833583static Type isRawRepresentable (Type fromType,
3584- ConstraintSystem *CS) {
3584+ const ConstraintSystem *CS) {
35853585 auto rawReprType =
35863586 CS->TC .getProtocol (SourceLoc (), KnownProtocolKind::RawRepresentable);
35873587 if (!rawReprType)
@@ -3604,7 +3604,7 @@ static Type isRawRepresentable(Type fromType,
36043604// / underlying type conforming to the given known protocol.
36053605static Type isRawRepresentable (Type fromType,
36063606 KnownProtocolKind kind,
3607- ConstraintSystem *CS) {
3607+ const ConstraintSystem *CS) {
36083608 Type rawTy = isRawRepresentable (fromType, CS);
36093609 if (!rawTy || !conformsToKnownProtocol (rawTy, kind, CS))
36103610 return Type ();
@@ -3635,11 +3635,11 @@ static bool isIntegerToStringIndexConversion(Type fromType, Type toType,
36353635// /
36363636// / This helps migration with SDK changes.
36373637static bool tryRawRepresentableFixIts (InFlightDiagnostic &diag,
3638- ConstraintSystem *CS,
3638+ const ConstraintSystem *CS,
36393639 Type fromType,
36403640 Type toType,
36413641 KnownProtocolKind kind,
3642- Expr *expr) {
3642+ const Expr *expr) {
36433643 // The following fixes apply for optional destination types as well.
36443644 bool toTypeIsOptional = !toType->getAnyOptionalObjectType ().isNull ();
36453645 toType = toType->lookThroughAllAnyOptionalTypes ();
@@ -3679,7 +3679,8 @@ static bool tryRawRepresentableFixIts(InFlightDiagnostic &diag,
36793679 std::string convWrapBefore = toType.getString ();
36803680 convWrapBefore += " (rawValue: " ;
36813681 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 )) {
36833684 // Only try to insert a converting construction if the protocol is a
36843685 // literal protocol and not some other known protocol.
36853686 switch (kind) {
0 commit comments