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(
368
368
PotentiallyIncomplete = true ;
369
369
}
370
370
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
+
371
380
addPotentialBinding (PotentialBinding::forHole (TypeVar, locator));
372
381
}
373
382
@@ -1268,6 +1277,8 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
1268
1277
return true ;
1269
1278
1270
1279
fix = SpecifyKeyPathRootType::create (cs, dstLocator);
1280
+ } else if (dstLocator->directlyAt <NilLiteralExpr>()) {
1281
+ fix = SpecifyContextualTypeForNil::create (cs, dstLocator);
1271
1282
}
1272
1283
1273
1284
if (fix && cs.recordFix (fix))
You can’t perform that action at this time.
0 commit comments