Skip to content

Commit 782d68f

Browse files
committed
Sema: Fix malformed AST when both DynamicSelfType and opened existentials are involved
This worked for functions, but for properties, we did things in the wrong order. Fixes rdar://160816868.
1 parent cc8f060 commit 782d68f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,6 @@ namespace {
18091809
result = adjustTypeForDeclReference(result, resultTySelf,
18101810
resultType(adjustedRefTySelf),
18111811
locator);
1812-
closeExistentials(result, locator);
18131812

18141813
// If the property is of dynamic 'Self' type, wrap an implicit
18151814
// conversion around the resulting expression, with the destination
@@ -1821,6 +1820,8 @@ namespace {
18211820
result, resultTy));
18221821
}
18231822

1823+
closeExistentials(result, locator);
1824+
18241825
// If we need to load, do so now.
18251826
if (loadImmediately) {
18261827
result = cs.addImplicitLoadExpr(result);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %target-swift-emit-silgen %s
2+
3+
public class C {
4+
public func f() -> Self { return self }
5+
public var v: Self { return self }
6+
public subscript() -> Self { return self }
7+
8+
public func g1() {}
9+
}
10+
11+
public protocol P {
12+
func g2()
13+
}
14+
15+
func f(_ p: any P & C) {
16+
p.f().g1()
17+
p.f().g2()
18+
19+
p.v.g1()
20+
p.v.g2()
21+
22+
// FIXME
23+
// p[].g1()
24+
// p[].g2()
25+
}
26+

0 commit comments

Comments
 (0)