// RUN: %target-swift-frontend -emit-ir %s public typealias OnValue = () -> Value public protocol SubjectProtocol { associatedtype Value func value() -> Value func onValue(_ onValue: @escaping OnValue) -> any SubjectProtocol } class Subject: SubjectProtocol { var _onValue: OnValue? init(_ onValue: OnValue?) { self._onValue = onValue } func value() -> Value { if let onValue = self._onValue { return onValue() } else { fatalError("Require Implementation") } } func onValue(_ onValue: @escaping OnValue) -> any SubjectProtocol { let subject = Subject(self._onValue) subject._onValue = onValue return subject } } public func ExistentialSubject() -> any SubjectProtocol { Subject(nil) } public func DebugSubject() { ExistentialSubject().onValue { 0 } }