Skip to content

Commit 0c364a7

Browse files
authored
Merge pull request swiftlang#77332 from xedin/inout-regression-after-delay
[CSBindings] Don't delay bindings inferred through `inout` conversion
2 parents 8b2a3a4 + 70ac657 commit 0c364a7

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,11 +1518,6 @@ PotentialBindings::inferFromRelational(Constraint *constraint) {
15181518
if (auto pointeeTy = second->lookThroughAllOptionalTypes()
15191519
->getAnyPointerElementType()) {
15201520
if (!pointeeTy->isTypeVariableOrMember()) {
1521-
// The binding is as a fallback in this case because $T could
1522-
// also be Array<X> or C-style pointer.
1523-
if (constraint->getKind() >= ConstraintKind::ArgumentConversion)
1524-
DelayedBy.push_back(constraint);
1525-
15261521
return PotentialBinding(pointeeTy, AllowedBindingKind::Exact,
15271522
constraint);
15281523
}

test/Constraints/valid_pointer_conversions.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,22 @@ do {
6969
test(&outputs[name]!) // Ok
7070
}
7171
}
72+
73+
do {
74+
func test<O>(_ initialValue: O, _ action: (inout O) -> Void) -> O {
75+
}
76+
77+
func compute(_: UnsafeMutablePointer<UInt8>!) {
78+
}
79+
80+
let result1 = test(0) { // `0` should be inferred as `UInt8`
81+
compute(&$0)
82+
}
83+
84+
let result2 = test([0]) { // `0` should be inferred as `UInt8`
85+
compute(&$0)
86+
}
87+
88+
let _: UInt8 = result1 // Ok
89+
let _: [UInt8] = result2 // Ok
90+
}

0 commit comments

Comments
 (0)