Skip to content

Commit 85f3679

Browse files
committed
[Test] Add a simple test case for a method with an opaque return type
and no return statements.
1 parent b9367d1 commit 85f3679

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/type/opaque.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ func recursion(x: Int) -> some P {
172172
return recursion(x: x - 1)
173173
}
174174

175-
func noReturnStmts() -> some P { // expected-note {{opaque return type declared here}}
176-
fatalError() // expected-error{{return type of global function 'noReturnStmts()' requires that 'Never' conform to 'P'}}
175+
func noReturnStmts() -> some P {} // expected-error {{function declares an opaque return type, but has no return statements in its body from which to infer an underlying type}}
176+
177+
func returnUninhabited() -> some P { // expected-note {{opaque return type declared here}}
178+
fatalError() // expected-error{{return type of global function 'returnUninhabited()' requires that 'Never' conform to 'P'}}
177179
}
178180

179181
func mismatchedReturnTypes(_ x: Bool, _ y: Int, _ z: String) -> some P { // expected-error{{do not have matching underlying types}}

0 commit comments

Comments
 (0)