Skip to content

Commit e48cb82

Browse files
authored
Merge pull request #11765 from graydon/rdar-34111449-missing-case-in-SILOptimizer-dataflow-diagnostics
[SILOptimizer] Handle a missing case in DataflowDiagnostics.cpp
2 parents 63ab590 + 8f42660 commit e48cb82

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/SILOptimizer/Mandatory/DataflowDiagnostics.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ static void diagnoseMissingReturn(const UnreachableInst *UI,
4343

4444
if (auto *FD = FLoc.getAsASTNode<FuncDecl>()) {
4545
ResTy = FD->getResultInterfaceType();
46+
} else if (auto *CD = FLoc.getAsASTNode<ConstructorDecl>()) {
47+
ResTy = CD->getResultInterfaceType();
4648
} else if (auto *CE = FLoc.getAsASTNode<ClosureExpr>()) {
4749
ResTy = CE->getResultType();
4850
} else {

test/SILOptimizer/return.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ func whileLoop(flag: Bool) -> Int {
9494
}
9595
} //expected-error {{missing return in a function expected to return 'Int'}}
9696

97+
struct S {}
98+
extension S:ExpressibleByStringLiteral {
99+
init!(stringLiteral:String) {
100+
} // expected-error {{missing return in a function expected to return 'S!'}}
101+
}
102+
97103
func whileTrueLoop() -> Int {
98104
var b = 1
99105
while (true) {

0 commit comments

Comments
 (0)