Skip to content

Commit 6ae3d5d

Browse files
committed
Only force immediate closure of an open existential when we opened one.
Fixes rdar://problem/21597711. Swift SVN r30190
1 parent da6d8c1 commit 6ae3d5d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ namespace {
956956

957957
ref->setType(refType);
958958

959-
closeExistential(ref, /*force=*/true);
959+
closeExistential(ref, /*force=*/openedExistential);
960960

961961
return ref;
962962
}
@@ -997,7 +997,7 @@ namespace {
997997
// Reference to an unbound instance method.
998998
Expr *result = new (context) DotSyntaxBaseIgnoredExpr(base, dotLoc,
999999
ref);
1000-
closeExistential(result, /*force=*/true);
1000+
closeExistential(result, /*force=*/openedExistential);
10011001
return result;
10021002
} else {
10031003
assert((!baseIsInstance || member->isInstanceMember()) &&

test/Constraints/existential_metatypes.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,17 @@ extension P2 {
7171
func testP2(pt: P2.Type) {
7272
pt.init().elements
7373
}
74+
75+
// rdar://problem/21597711
76+
protocol P3 {
77+
func withP3(fn: (P3) -> ())
78+
}
79+
80+
class Something {
81+
func takeP3(p: P3) { }
82+
}
83+
84+
85+
func testP3(p: P3, something: Something) {
86+
p.withP3(Something.takeP3(something))
87+
}

0 commit comments

Comments
 (0)