File tree Expand file tree Collapse file tree 4 files changed +63
-93
lines changed Expand file tree Collapse file tree 4 files changed +63
-93
lines changed Original file line number Diff line number Diff line change @@ -1094,13 +1094,6 @@ bool BindingSet::favoredOverConjunction(Constraint *conjunction) const {
1094
1094
if (locator->directlyAt <ClosureExpr>()) {
1095
1095
auto *closure = castToExpr<ClosureExpr>(locator->getAnchor ());
1096
1096
1097
- // If there are no bindings for the closure yet we cannot prioritize
1098
- // it because that runs into risk of missing a result builder transform.
1099
- if (TypeVar->getImpl ().isClosureType ()) {
1100
- if (Bindings.empty ())
1101
- return false ;
1102
- }
1103
-
1104
1097
if (auto transform = CS.getAppliedResultBuilderTransform (closure)) {
1105
1098
// Conjunctions that represent closures with result builder transformed
1106
1099
// bodies could be attempted right after their resolution if they meet
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ // rdar://113745963
4
+
5
+ // https://github.com/apple/swift/pull/67441 changed closure resolution order which makes the following code fail to type-check.
6
+
7
+ struct Date : Equatable {
8
+ static var distantPast = Date ( )
9
+ }
10
+
11
+ enum Request {
12
+ struct Options : OptionSet {
13
+ static let option1 = Options ( rawValue: 1 << 0 )
14
+ static let option2 = Options ( rawValue: 1 << 1 )
15
+
16
+ let rawValue : Int
17
+
18
+ init ( rawValue: Int ) {
19
+ self . rawValue = rawValue
20
+ }
21
+ }
22
+
23
+ enum Source : Comparable {
24
+ case automatic
25
+ case manual( Date )
26
+
27
+ static func < ( lhs: Source , rhs: Source ) -> Bool { true }
28
+ }
29
+
30
+ case problem( options: Options , source: Source )
31
+ }
32
+
33
+ enum OuterSource {
34
+ case automatic, manual, unknown
35
+ }
36
+
37
+ struct Test {
38
+ func test( arr: [ Int ] ) {
39
+ let _: [ Request ] = arr. map { value in
40
+ let source : OuterSource = . automatic
41
+ let dateAdded = Date . distantPast
42
+ return . problem(
43
+ options: {
44
+ switch source {
45
+ case . automatic:
46
+ return [ . option1, . option2]
47
+ case . manual, . unknown:
48
+ return [ ]
49
+ }
50
+ } ( ) ,
51
+ source: {
52
+ switch source {
53
+ case . manual:
54
+ return . manual( dateAdded)
55
+ case . automatic, . unknown:
56
+ return . automatic
57
+ }
58
+ } ( ) )
59
+ }
60
+ }
61
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -713,7 +713,8 @@ func test_result_builder_in_member_chaining() {
713
713
Test . test {
714
714
let test = Test ( )
715
715
return test
716
- } . builder { // Ok
716
+ // FIXME: This call should type-check, currently closure is resolved before overload of `builder` is picked.
717
+ } . builder { // expected-error {{cannot convert value of type '()' to closure result type 'Int'}}
717
718
let result = " "
718
719
result
719
720
}
You can’t perform that action at this time.
0 commit comments