File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -11402,6 +11402,7 @@ ConstraintSystem::simplifyApplicableFnConstraint(
11402
11402
FunctionType::get(trailingClosureTypes, callAsFunctionResultTy,
11403
11403
FunctionType::ExtInfo());
11404
11404
11405
+ increaseScore(SK_DisfavoredOverload);
11405
11406
// Form an unsolved constraint to apply trailing closures to a
11406
11407
// callable type produced by `.init`. This constraint would become
11407
11408
// active when `callableType` is bound.
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 -debug-constraints > %t.log 2>&1
2
+ // RUN: %FileCheck %s < %t.log
3
+
4
+ // REQUIRES: objc_interop
5
+ // REQUIRES: OS=macosx
6
+
7
+ protocol View { }
8
+ protocol Callable { }
9
+
10
+ struct EmptyView : View { }
11
+
12
+ @resultBuilder struct ViewBuilder {
13
+ static func buildBlock< Content> ( _ content: Content ) -> Content where Content : View { fatalError ( ) }
14
+ }
15
+
16
+ extension Callable {
17
+ func callAsFunction< T: View > ( @ViewBuilder _: ( ) -> T ) -> some View { EmptyView ( ) }
18
+ }
19
+
20
+ struct MyView < Content> : View {
21
+ init ( v: Int , @ViewBuilder _: ( ) -> Content ) { }
22
+ }
23
+
24
+ extension MyView : Callable where Content == EmptyView {
25
+ init ( v: Int ) { }
26
+ }
27
+
28
+ // CHECK: (overload set choice binding $T6 := (Int) -> MyView<{{.*}}>)
29
+ // CHECK-NEXT: (increasing score due to disfavored overload)
30
+ // CHECK-NEXT: (solution is worse than the best solution)
31
+
32
+ func test( ) -> some View {
33
+ return MyView ( v: 42 ) {
34
+ return EmptyView ( )
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments