Skip to content

Commit 945790a

Browse files
committed
as! and as? also indicate suppression of implicit existential opening
1 parent 5f99c31 commit 945790a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,9 +1478,9 @@ shouldOpenExistentialCallArgument(
14781478
// An argument expression that explicitly coerces to an existential
14791479
// disables the implicit opening of the existential.
14801480
if (argExpr) {
1481-
if (auto argCoercion = dyn_cast<CoerceExpr>(
1481+
if (auto argCast = dyn_cast<ExplicitCastExpr>(
14821482
argExpr->getSemanticsProvidingExpr())) {
1483-
if (auto typeRepr = argCoercion->getCastTypeRepr()) {
1483+
if (auto typeRepr = argCast->getCastTypeRepr()) {
14841484
if (auto toType = cs.getType(typeRepr)) {
14851485
if (toType->isAnyExistentialType())
14861486
return None;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// RUN: %target-swift-frontend -enable-experimental-opened-existential-types -typecheck -dump-ast -parse-as-library %s | %FileCheck %s
22

33
protocol P { }
4+
extension Optional: P where Wrapped: P { }
45

56
func acceptsBox<T>(_ value: T) { }
67

78
// CHECK: passBox
89
// CHECK-NOT: open_existential_expr
910
func passBox(p: P, obj: AnyObject, err: Error) {
1011
acceptsBox(p as P)
12+
acceptsBox(p as! P)
13+
acceptsBox(p as? P)
1114
acceptsBox(obj)
1215
acceptsBox(err)
1316
}

0 commit comments

Comments
 (0)