File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -212,7 +212,22 @@ void StmtEmitter::visitBraceStmt(BraceStmt *S) {
212
212
if (auto *S = ESD.dyn_cast <Stmt*>()) {
213
213
if (S->isImplicit ()) continue ;
214
214
} else if (auto *E = ESD.dyn_cast <Expr*>()) {
215
- if (E->isImplicit ()) continue ;
215
+ // Optional chaining expressions are wrapped in a structure like.
216
+ //
217
+ // (optional_evaluation_expr implicit type='T?'
218
+ // (call_expr type='T?'
219
+ // (exprs...
220
+ //
221
+ // Walk through it to find out if the statement is actually implicit.
222
+ if (auto *OEE = dyn_cast<OptionalEvaluationExpr>(E)) {
223
+ if (auto *IIO = dyn_cast<InjectIntoOptionalExpr>(OEE->getSubExpr ()))
224
+ if (IIO->getSubExpr ()->isImplicit ()) continue ;
225
+ if (auto *C = dyn_cast<CallExpr>(OEE->getSubExpr ()))
226
+ if (C->isImplicit ()) continue ;
227
+ } else if (E->isImplicit ()) {
228
+ // Ignore all other implicit expressions.
229
+ continue ;
230
+ }
216
231
}
217
232
218
233
if (StmtType != UnknownStmtType) {
Original file line number Diff line number Diff line change @@ -111,6 +111,15 @@ func testUnreachableCase5(a : Tree) {
111
111
}
112
112
}
113
113
114
+ func testOptionalEvaluationBreak( a : Tree ) {
115
+ class SR5763 { func foo( ) { } }
116
+ func createOptional( ) -> SR5763 ? { return SR5763 ( ) }
117
+ switch a {
118
+ case _:
119
+ break
120
+ createOptional ( ) ? . foo ( ) // expected-warning {{code after 'break' will never be executed}}
121
+ }
122
+ }
114
123
115
124
func testUnreachableAfterThrow( e: Error ) throws {
116
125
throw e
You can’t perform that action at this time.
0 commit comments