Skip to content

Commit

Permalink
Discourage constraint systems that use more unchecked forces.
Browse files Browse the repository at this point in the history
This is in preparation for a change that allows unchecked-optional
values to be implicitly forced in all contexts.

Swift SVN r14704
  • Loading branch information
rjmccall committed Mar 6, 2014
1 parent 2aa197f commit e38a2b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Sema/CSSimplify.cpp
Expand Up @@ -1360,6 +1360,7 @@ ConstraintSystem::simplifyMemberConstraint(const Constraint &constraint) {

// Try to look through UncheckedOptional<T>; the result is always an r-value.
if (auto objTy = lookThroughUncheckedOptionalType(baseObjTy)) {
increaseScore(SK_UncheckedForce);
baseTy = baseObjTy = objTy;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Sema/ConstraintSystem.h
Expand Up @@ -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.
Expand All @@ -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 {
Expand Down

0 comments on commit e38a2b9

Please sign in to comment.