@@ -3571,7 +3571,7 @@ bool FailureDiagnosis::diagnoseCalleeResultContextualConversionError() {
35713571// / Return true if the given type conforms to a known protocol type.
35723572static bool conformsToKnownProtocol (Type fromType,
35733573 KnownProtocolKind kind,
3574- ConstraintSystem *CS) {
3574+ const ConstraintSystem *CS) {
35753575 auto proto = CS->TC .getProtocol (SourceLoc (), kind);
35763576 if (!proto)
35773577 return false ;
@@ -3584,15 +3584,15 @@ static bool conformsToKnownProtocol(Type fromType,
35843584 return false ;
35853585}
35863586
3587- static bool isIntegerType (Type fromType, ConstraintSystem *CS) {
3587+ static bool isIntegerType (Type fromType, const ConstraintSystem *CS) {
35883588 return conformsToKnownProtocol (fromType,
35893589 KnownProtocolKind::ExpressibleByIntegerLiteral,
35903590 CS);
35913591}
35923592
35933593// / Return true if the given type conforms to RawRepresentable.
35943594static Type isRawRepresentable (Type fromType,
3595- ConstraintSystem *CS) {
3595+ const ConstraintSystem *CS) {
35963596 auto rawReprType =
35973597 CS->TC .getProtocol (SourceLoc (), KnownProtocolKind::RawRepresentable);
35983598 if (!rawReprType)
@@ -3615,7 +3615,7 @@ static Type isRawRepresentable(Type fromType,
36153615// / underlying type conforming to the given known protocol.
36163616static Type isRawRepresentable (Type fromType,
36173617 KnownProtocolKind kind,
3618- ConstraintSystem *CS) {
3618+ const ConstraintSystem *CS) {
36193619 Type rawTy = isRawRepresentable (fromType, CS);
36203620 if (!rawTy || !conformsToKnownProtocol (rawTy, kind, CS))
36213621 return Type ();
@@ -3646,11 +3646,11 @@ static bool isIntegerToStringIndexConversion(Type fromType, Type toType,
36463646// /
36473647// / This helps migration with SDK changes.
36483648static bool tryRawRepresentableFixIts (InFlightDiagnostic &diag,
3649- ConstraintSystem *CS,
3649+ const ConstraintSystem *CS,
36503650 Type fromType,
36513651 Type toType,
36523652 KnownProtocolKind kind,
3653- Expr *expr) {
3653+ const Expr *expr) {
36543654 // The following fixes apply for optional destination types as well.
36553655 bool toTypeIsOptional = !toType->getAnyOptionalObjectType ().isNull ();
36563656 toType = toType->lookThroughAllAnyOptionalTypes ();
@@ -3690,7 +3690,8 @@ static bool tryRawRepresentableFixIts(InFlightDiagnostic &diag,
36903690 std::string convWrapBefore = toType.getString ();
36913691 convWrapBefore += " (rawValue: " ;
36923692 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 )) {
36943695 // Only try to insert a converting construction if the protocol is a
36953696 // literal protocol and not some other known protocol.
36963697 switch (kind) {
0 commit comments