Skip to content

Commit e30bdac

Browse files
committed
[CSBindings] Adjust impact of an event when nil is bound to a hole
1 parent 1b5ce2b commit e30bdac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,8 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
12391239
cs.increaseScore(SK_Hole);
12401240

12411241
ConstraintFix *fix = nullptr;
1242+
unsigned fixImpact = 1;
1243+
12421244
if (auto *GP = TypeVar->getImpl().getGenericParameter()) {
12431245
// If it is represetative for a key path root, let's emit a more
12441246
// specific diagnostic.
@@ -1279,9 +1281,12 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
12791281
fix = SpecifyKeyPathRootType::create(cs, dstLocator);
12801282
} else if (dstLocator->directlyAt<NilLiteralExpr>()) {
12811283
fix = SpecifyContextualTypeForNil::create(cs, dstLocator);
1284+
// This is a dramatic event, it means that there is absolutely
1285+
// no contextual information to resolve type of `nil`.
1286+
fixImpact = 10;
12821287
}
12831288

1284-
if (fix && cs.recordFix(fix))
1289+
if (fix && cs.recordFix(fix, fixImpact))
12851290
return true;
12861291
}
12871292
}

0 commit comments

Comments
 (0)