Skip to content

Commit e320fa7

Browse files
authored
Merge pull request #21833 from theblixguy/fix/SR-9646
[Sema] Look through OpenExistentialExpr in checkIgnoreExpr()
2 parents ecebce8 + 54a53c2 commit e320fa7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,8 @@ void TypeChecker::checkIgnoredExpr(Expr *E) {
13121312
return checkIgnoredExpr(IIO->getSubExpr());
13131313
if (auto *C = dyn_cast<CallExpr>(OEE->getSubExpr()))
13141314
return checkIgnoredExpr(C);
1315+
if (auto *OE = dyn_cast<OpenExistentialExpr>(OEE->getSubExpr()))
1316+
return checkIgnoredExpr(OE);
13151317
}
13161318

13171319
if (auto *LE = dyn_cast<LiteralExpr>(valueE)) {

test/attr/attr_discardableResult.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,20 @@ class SR7562_B : SR7562_A {}
194194

195195
SR7562_A(input: 10) // okay
196196
SR7562_B(input: 10) // okay
197+
198+
protocol FooProtocol {}
199+
200+
extension FooProtocol {
201+
@discardableResult
202+
static func returnSomething() -> Bool? {
203+
return true
204+
}
205+
}
206+
207+
class Foo {
208+
var myOptionalFooProtocol: FooProtocol.Type?
209+
210+
func doSomething() {
211+
myOptionalFooProtocol?.returnSomething() // okay
212+
}
213+
}

0 commit comments

Comments
 (0)