Skip to content

Commit edb21b2

Browse files
authored
Merge pull request #19980 from xedin/rdar-45415874
[ConstraintSystem] Properly cache type for literal initialization coe…
2 parents b0c8fc5 + 4197cfd commit edb21b2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3599,6 +3599,7 @@ namespace {
35993599

36003600
literalInit->setImplicit(false);
36013601

3602+
cs.setType(expr, toType);
36023603
// Keep the coercion around, because it contains the source range
36033604
// for the original constructor call.
36043605
return expr;

test/Constraints/rdar45415874.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
final class A<T> {
4+
init(_: T) {}
5+
}
6+
7+
extension A: ExpressibleByNilLiteral where T: ExpressibleByNilLiteral {
8+
convenience init(nilLiteral: ()) {
9+
self.init(nil)
10+
}
11+
}
12+
13+
struct B {
14+
var foo: A<B?> = A(nil)
15+
}

0 commit comments

Comments
 (0)