File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
validation-test/Sema/SwiftUI Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -794,6 +794,10 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() {
794
794
} else {
795
795
const auto &last = path.back ();
796
796
switch (last.getKind ()) {
797
+ case ConstraintLocator::TernaryBranch:
798
+ diagnostic = diag::ternary_expr_cases_mismatch;
799
+ break ;
800
+
797
801
case ConstraintLocator::ContextualType: {
798
802
auto purpose = getContextualTypePurpose ();
799
803
assert (!(purpose == CTP_Unused || purpose == CTP_CannotFail));
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5
2
+ // REQUIRES: objc_interop
3
+ // REQUIRES: OS=macosx
4
+
5
+ import SwiftUI
6
+
7
+ struct NewBounds {
8
+ var minBinding : Binding < Double > !
9
+ var maxBinding : Binding < Double > !
10
+ }
11
+
12
+ func test< V> (
13
+ value: Binding < V > ,
14
+ in bounds: ClosedRange < V >
15
+ ) -> some View where V : BinaryFloatingPoint , V. Stride : BinaryFloatingPoint {
16
+ EmptyView ( )
17
+ }
18
+
19
+ struct MyView : View {
20
+ @State var newBounds : NewBounds
21
+ var bounds : ClosedRange < Double >
22
+
23
+ var body : some View {
24
+ test ( value: true ? $newBounds. maxBinding : $newBounds. minBinding, in: bounds)
25
+ // expected-error@-1 2 {{result values in '? :' expression have mismatching types 'Binding<Binding<Double>?>' and 'Binding<Double>'}}
26
+ // expected-note@-2 2 {{arguments to generic parameter 'Value' ('Binding<Double>?' and 'Double') are expected to be equal}}
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments