mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[test] Add test case for issue 71040
This commit is contained in:
26
test/Constraints/issue-71040.swift
Normal file
26
test/Constraints/issue-71040.swift
Normal file
@@ -0,0 +1,26 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/71040
|
||||
|
||||
@resultBuilder
|
||||
struct Builder {
|
||||
static func buildBlock<T>(_ components: T...) -> T {
|
||||
components.first!
|
||||
}
|
||||
}
|
||||
|
||||
struct S<T> {
|
||||
init(_ fn: () -> T) {}
|
||||
}
|
||||
|
||||
func foo<T>(@Builder _ fn: () -> T) {}
|
||||
|
||||
@Builder
|
||||
func bar() {
|
||||
foo {
|
||||
S<Int> {
|
||||
let x = if .random() { 0 } else { 1 }
|
||||
return x
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user