mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Destroys of values whose types feature a pack may require allocating the pack on-stack. Thanks to @slavapestov for the test case. rdar://112792831
42 lines
1.2 KiB
Swift
42 lines
1.2 KiB
Swift
// RUN: %target-swift-frontend -emit-ir -O %s
|
|
|
|
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
|
public struct Predicate<each Input> {
|
|
var x: Any? = nil
|
|
public func evaluate(_: repeat each Input) -> Bool { return false }
|
|
}
|
|
|
|
public struct PredicateBindings {
|
|
}
|
|
|
|
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
|
public protocol PredicateExpression<Output> {
|
|
associatedtype Output
|
|
|
|
func evaluate(_ bindings: PredicateBindings) throws -> Output
|
|
}
|
|
|
|
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
|
public struct PredicateEvaluate<
|
|
Condition : PredicateExpression,
|
|
each Input : PredicateExpression
|
|
>
|
|
where
|
|
Condition.Output == Predicate<repeat (each Input).Output>
|
|
{
|
|
|
|
public typealias Output = Bool
|
|
|
|
public let predicate: Condition
|
|
public let input: (repeat each Input)
|
|
|
|
public init(predicate: Condition, input: repeat each Input) {
|
|
self.predicate = predicate
|
|
self.input = (repeat each input)
|
|
}
|
|
|
|
public func evaluate(_ bindings: PredicateBindings) throws -> Output {
|
|
try predicate.evaluate(bindings).evaluate(repeat (each input).evaluate(bindings))
|
|
}
|
|
}
|