Files
swift-mirror/validation-test/Sema/SwiftUI/rdar98862079.swift
Pavel Yaskevich 2b11ecbec9 [CSBindings] Limit BindingSet::isViable binding skipping to stdlib collection types
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
2024-10-21 14:48:45 -07:00

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}}
}
}