Skip to content

Revert "[CSBindings] Detect situations when type variable bindings co… #20473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions lib/Sema/CSBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,6 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
case ConstraintKind::ArgumentConversion:
case ConstraintKind::OperatorArgumentConversion:
case ConstraintKind::OptionalObject: {
// If there is a `bind param` constraint associated with
// current type variable, result should be aware of that
// fact. Binding set might be incomplete until
// this constraint is resolved, because we currently don't
// look-through constraints expect to `subtype` to try and
// find related bindings.
if (constraint->getKind() == ConstraintKind::BindParam)
result.PotentiallyIncomplete = true;

auto binding = getPotentialBindingForRelationalConstraint(
result, constraint, hasDependentMemberRelationalConstraints,
hasNonDependentMemberRelationalConstraints,
Expand Down
17 changes: 2 additions & 15 deletions lib/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -2831,12 +2831,6 @@ class ConstraintSystem {
/// Whether the bindings of this type involve other type variables.
bool InvolvesTypeVariables = false;

/// Whether the bindings represent (potentially) incomplete set,
/// there is no way to say with absolute certainty if that's the
/// case, but that could happen when certain constraints like
/// `bind param` are present in the system.
bool PotentiallyIncomplete = false;

/// Whether this type variable has literal bindings.
LiteralBindingKind LiteralBinding = LiteralBindingKind::None;

Expand Down Expand Up @@ -2881,14 +2875,9 @@ class ConstraintSystem {
if (formBindingScore(y) < formBindingScore(x))
return false;

// If there is a difference in number of default types,
// If the only difference is default types,
// prioritize bindings with fewer of them.
if (x.NumDefaultableBindings != y.NumDefaultableBindings)
return x.NumDefaultableBindings < y.NumDefaultableBindings;

// As a last resort, let's check if the bindings are
// potentially incomplete, and if so, let's de-prioritize them.
return x.PotentiallyIncomplete < y.PotentiallyIncomplete;
return x.NumDefaultableBindings < y.NumDefaultableBindings;
}

void foundLiteralBinding(ProtocolDecl *proto) {
Expand Down Expand Up @@ -2921,8 +2910,6 @@ class ConstraintSystem {
void dump(llvm::raw_ostream &out,
unsigned indent = 0) const LLVM_ATTRIBUTE_USED {
out.indent(indent);
if (PotentiallyIncomplete)
out << "potentially_incomplete ";
if (FullyBound)
out << "fully_bound ";
if (SubtypeOfExistentialType)
Expand Down
10 changes: 1 addition & 9 deletions test/Constraints/closures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -798,15 +798,6 @@ func test<Instances : Collection>(

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

// rdar://problem/45659733
func rdar_45659733() {
func foo<T : BinaryInteger>(_: AnyHashable, _: T) {}
func bar(_ a: Int, _ b: Int) {
_ = (a ..< b).map { i in foo(i, i) } // Ok
}
}


// rdar://problem/40537960 - Misleading diagnostic when using closure with wrong type

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