Skip to content

Commit c4c9cc3

Browse files
committed
Revert "[CSBindings] Detect situations when type variable bindings could be incomplete"
This reverts commit 4f70889.
1 parent a1ae75b commit c4c9cc3

File tree

3 files changed

+3
-33
lines changed

3 files changed

+3
-33
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,6 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
424424
case ConstraintKind::ArgumentConversion:
425425
case ConstraintKind::OperatorArgumentConversion:
426426
case ConstraintKind::OptionalObject: {
427-
// If there is a `bind param` constraint associated with
428-
// current type variable, result should be aware of that
429-
// fact. Binding set might be incomplete until
430-
// this constraint is resolved, because we currently don't
431-
// look-through constraints expect to `subtype` to try and
432-
// find related bindings.
433-
if (constraint->getKind() == ConstraintKind::BindParam)
434-
result.PotentiallyIncomplete = true;
435-
436427
auto binding = getPotentialBindingForRelationalConstraint(
437428
result, constraint, hasDependentMemberRelationalConstraints,
438429
hasNonDependentMemberRelationalConstraints,

lib/Sema/ConstraintSystem.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,12 +2831,6 @@ class ConstraintSystem {
28312831
/// Whether the bindings of this type involve other type variables.
28322832
bool InvolvesTypeVariables = false;
28332833

2834-
/// Whether the bindings represent (potentially) incomplete set,
2835-
/// there is no way to say with absolute certainty if that's the
2836-
/// case, but that could happen when certain constraints like
2837-
/// `bind param` are present in the system.
2838-
bool PotentiallyIncomplete = false;
2839-
28402834
/// Whether this type variable has literal bindings.
28412835
LiteralBindingKind LiteralBinding = LiteralBindingKind::None;
28422836

@@ -2881,14 +2875,9 @@ class ConstraintSystem {
28812875
if (formBindingScore(y) < formBindingScore(x))
28822876
return false;
28832877

2884-
// If there is a difference in number of default types,
2878+
// If the only difference is default types,
28852879
// prioritize bindings with fewer of them.
2886-
if (x.NumDefaultableBindings != y.NumDefaultableBindings)
2887-
return x.NumDefaultableBindings < y.NumDefaultableBindings;
2888-
2889-
// As a last resort, let's check if the bindings are
2890-
// potentially incomplete, and if so, let's de-prioritize them.
2891-
return x.PotentiallyIncomplete < y.PotentiallyIncomplete;
2880+
return x.NumDefaultableBindings < y.NumDefaultableBindings;
28922881
}
28932882

28942883
void foundLiteralBinding(ProtocolDecl *proto) {
@@ -2921,8 +2910,6 @@ class ConstraintSystem {
29212910
void dump(llvm::raw_ostream &out,
29222911
unsigned indent = 0) const LLVM_ATTRIBUTE_USED {
29232912
out.indent(indent);
2924-
if (PotentiallyIncomplete)
2925-
out << "potentially_incomplete ";
29262913
if (FullyBound)
29272914
out << "fully_bound ";
29282915
if (SubtypeOfExistentialType)

test/Constraints/closures.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -798,15 +798,6 @@ func test<Instances : Collection>(
798798

799799
test([1]) { _, _ in fatalError(); () }
800800

801-
// rdar://problem/45659733
802-
func rdar_45659733() {
803-
func foo<T : BinaryInteger>(_: AnyHashable, _: T) {}
804-
func bar(_ a: Int, _ b: Int) {
805-
_ = (a ..< b).map { i in foo(i, i) } // Ok
806-
}
807-
}
808-
809-
810801
// rdar://problem/40537960 - Misleading diagnostic when using closure with wrong type
811802

812803
protocol P_40537960 {}
@@ -831,3 +822,4 @@ func rdar_40537960() {
831822
var arr: [S] = []
832823
_ = A(arr, fn: { L($0.v) }) // expected-error {{cannot convert value of type 'L' to closure result type 'R<T>'}}
833824
}
825+

0 commit comments

Comments
 (0)