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(
1140211402 FunctionType::get(trailingClosureTypes, callAsFunctionResultTy,
1140311403 FunctionType::ExtInfo());
1140411404
11405+ increaseScore(SK_DisfavoredOverload);
1140511406 // Form an unsolved constraint to apply trailing closures to a
1140611407 // callable type produced by `.init`. This constraint would become
1140711408 // 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