mirror of
https://github.com/apple/swift.git
synced 2026-10-16 16:50:49 +02:00
This is a version of -emit-silgen that emits the earliest "complete" OSSA SIL right after SILGen. It does ownership verification prior to emission. This is handy for people just wanting to ensure programs can make it through SILGen correctly and emit valid Raw SIL, without running any extra SIL passes or triggering any of the diagnostics in the mandatory SIL pipeline. Combining it with `-sil-verify-all` gives you extra assurance that the SIL coming out of SILGen is right even prior to the clean-up. Asserts builds will do that automatically.
45 lines
676 B
Swift
45 lines
676 B
Swift
// RUN: %target-swift-emit-silgen-ossa %s
|
|
|
|
func f0<V>(_: () -> any P<V>) {}
|
|
func f1<V>(_: V.Type, _: () -> any P<V>) {}
|
|
func f2<V>(_: (V) -> (), _: () -> any P<V>) {}
|
|
|
|
protocol P<A> {
|
|
associatedtype A
|
|
}
|
|
|
|
struct G<A>: P {}
|
|
|
|
func g1() -> some P<Int> {
|
|
return G<Int>()
|
|
}
|
|
|
|
class B {}
|
|
class C: B {}
|
|
class D: C, P {
|
|
typealias A = Bool
|
|
}
|
|
|
|
func g2() -> some C & P {
|
|
return D()
|
|
}
|
|
|
|
func g3() -> (some P<Bool>, some C & P) {
|
|
return (G<Bool>(), D())
|
|
}
|
|
|
|
func test() {
|
|
let _: () -> any P<Int> = g1
|
|
let _: () -> B = g2
|
|
let _: () -> (any P, B) = g3
|
|
|
|
f0(g1)
|
|
f1(Int.self, g1)
|
|
f2({ $0 as Int }, g1)
|
|
|
|
f0({ g1() })
|
|
f1(Int.self, { g1() })
|
|
f2({ $0 as Int }, { g1() })
|
|
}
|
|
|