mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This is follow-up to https://github.com/swiftlang/swift/pull/76487 It's reasonable to coalesce bindings of different kind if they don't allow implicit conversions like stdlib collection types do. Resolves: https://github.com/swiftlang/swift/issues/77003
29 lines
881 B
Swift
29 lines
881 B
Swift
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5
|
|
// REQUIRES: objc_interop
|
|
// REQUIRES: OS=macosx
|
|
|
|
import SwiftUI
|
|
|
|
struct NewBounds {
|
|
var minBinding: Binding<Double>!
|
|
var maxBinding: Binding<Double>!
|
|
}
|
|
|
|
func test<V>(
|
|
value: Binding<V>,
|
|
in bounds: ClosedRange<V>
|
|
) -> some View where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint {
|
|
EmptyView()
|
|
}
|
|
|
|
struct MyView : View {
|
|
@State var newBounds: NewBounds
|
|
var bounds: ClosedRange<Double>
|
|
|
|
var body: some View {
|
|
test(value: true ? $newBounds.maxBinding : $newBounds.minBinding, in: bounds)
|
|
// expected-error@-1 2 {{result values in '? :' expression have mismatching types 'Binding<Binding<Double>?>' and 'Binding<Double>'}}
|
|
// expected-note@-2 2 {{arguments to generic parameter 'Value' ('Binding<Double>?' and 'Double') are expected to be equal}}
|
|
}
|
|
}
|