File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -2147,6 +2147,14 @@ TypeVariableBinding::fixForHole(ConstraintSystem &cs) const {
21472147 }
21482148
21492149 if (srcLocator->isLastElement <LocatorPathElt::PlaceholderType>()) {
2150+ // When a 'nil' has a placeholder as contextual type there is not enough
2151+ // information to resolve it, so let's record a specify contextual type for
2152+ // nil fix.
2153+ if (isExpr<NilLiteralExpr>(srcLocator->getAnchor ())) {
2154+ ConstraintFix *fix = SpecifyContextualTypeForNil::create (cs, dstLocator);
2155+ return std::make_pair (fix, /* impact=*/ (unsigned )10 );
2156+ }
2157+
21502158 ConstraintFix *fix = SpecifyTypeForPlaceholder::create (cs, srcLocator);
21512159 return std::make_pair (fix, defaultImpact);
21522160 }
Original file line number Diff line number Diff line change @@ -266,3 +266,7 @@ func deferredInit(_ c: Bool) {
266266 x = " Goodbye "
267267 }
268268}
269+
270+ // https://github.com/apple/swift/issues/63130
271+ let _: _ = nil // expected-error{{'nil' requires a contextual type}}
272+ let _: _ ? = nil // expected-error{{'nil' requires a contextual type}}
You can’t perform that action at this time.
0 commit comments