File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,15 @@ void ConstraintSystem::PotentialBindings::finalize(
368368 PotentiallyIncomplete = true ;
369369 }
370370
371+ // Delay resolution of the `nil` literal to a hole until
372+ // the very end to give it a change to be bound to some
373+ // other type, just like code completion expression which
374+ // relies solely on contextual information.
375+ if (locator->directlyAt <NilLiteralExpr>()) {
376+ FullyBound = true ;
377+ PotentiallyIncomplete = true ;
378+ }
379+
371380 addPotentialBinding (PotentialBinding::forHole (TypeVar, locator));
372381 }
373382
@@ -1268,6 +1277,8 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
12681277 return true ;
12691278
12701279 fix = SpecifyKeyPathRootType::create (cs, dstLocator);
1280+ } else if (dstLocator->directlyAt <NilLiteralExpr>()) {
1281+ fix = SpecifyContextualTypeForNil::create (cs, dstLocator);
12711282 }
12721283
12731284 if (fix && cs.recordFix (fix))
You can’t perform that action at this time.
0 commit comments