Skip to content

[Type checker] Eliminate generation of useless constraints NFC. #5261

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
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
6 changes: 6 additions & 0 deletions lib/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3313,6 +3313,12 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
}
}

// If the right-hand side and result type are both type parameters, we're
// not providing a useful completion.
if (expr->getType()->isTypeParameter() &&
CCE.getType()->isTypeParameter())
return;

addInfixOperatorCompletion(op, expr->getType(), CCE.getType());
}
}
Expand Down
19 changes: 0 additions & 19 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,25 +468,6 @@ namespace {
FunctionRefKind::Compound,
locator));

if (!archetype) {
// If the nested type is not an archetype (because it was constrained
// to a concrete type by a requirement), return the fresh type
// variable now, and let binding occur during overload resolution.
return memberTypeVar;
}

// FIXME: Would be better to walk the requirements of the protocol
// of which the associated type is a member.
if (auto superclass = member->getSuperclass()) {
CS.addConstraint(ConstraintKind::Subtype, memberTypeVar,
superclass, locator);
}

for (auto proto : member->getConformingProtocols()) {
CS.addConstraint(ConstraintKind::ConformsTo, memberTypeVar,
proto->getDeclaredType(), locator);
}

return memberTypeVar;
});
}
Expand Down