From e38a2b9a0820ec060e4c51c0f325d95234f4544b Mon Sep 17 00:00:00 2001 From: John McCall Date: Thu, 6 Mar 2014 00:18:41 +0000 Subject: [PATCH] Discourage constraint systems that use more unchecked forces. This is in preparation for a change that allows unchecked-optional values to be implicitly forced in all contexts. Swift SVN r14704 --- lib/Sema/CSSimplify.cpp | 1 + lib/Sema/ConstraintSystem.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 386a662d1f7e2..e5f27db2385ca 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -1360,6 +1360,7 @@ ConstraintSystem::simplifyMemberConstraint(const Constraint &constraint) { // Try to look through UncheckedOptional; the result is always an r-value. if (auto objTy = lookThroughUncheckedOptionalType(baseObjTy)) { + increaseScore(SK_UncheckedForce); baseTy = baseObjTy = objTy; } diff --git a/lib/Sema/ConstraintSystem.h b/lib/Sema/ConstraintSystem.h index f6268dff68771..8d3463d7af302 100644 --- a/lib/Sema/ConstraintSystem.h +++ b/lib/Sema/ConstraintSystem.h @@ -584,6 +584,8 @@ struct SelectedOverload { enum ScoreKind { // These values are used as indices into a Score value. + /// An implicit force of an unchecked optional value. + SK_UncheckedForce, /// A user-defined conversion. SK_UserConversion, /// A non-trivial function conversion. @@ -593,7 +595,7 @@ enum ScoreKind { }; /// The number of score kinds. -const unsigned NumScoreKinds = 3; +const unsigned NumScoreKinds = 4; /// Describes the fixed score of a solution to the constraint system. struct Score {