Files
swift-mirror/test/SILGen/dependency_through_closure.swift
2025-06-07 12:49:01 -07:00

24 lines
580 B
Swift

// RUN: %target-swift-emit-silgen -verify -enable-experimental-feature Lifetimes -enable-experimental-feature AddressableTypes %s
// REQUIRES: swift_feature_Lifetimes
// REQUIRES: swift_feature_AddressableTypes
@_addressableForDependencies
struct Owner {
@_lifetime(borrow self)
func reference() -> Reference { fatalError() }
}
struct Reference: ~Escapable {
@_lifetime(immortal)
init() { fatalError() }
func use() {}
}
func closure(_: () -> Void) {}
func dependencyThroughClosure(from owner: borrowing Owner) {
closure { owner.reference().use() }
}