Skip to content

Commit c5de105

Browse files
committed
Sema: Workaround for invalid logic in Solution::simplifyTypeForCodeCompletion()
1 parent 6ff8f55 commit c5de105

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,8 +1806,15 @@ Type Solution::simplifyTypeForCodeCompletion(Type Ty) const {
18061806
// variable representing the argument to retrieve protocol requirements from
18071807
// it. Look for a ArgumentConversion constraint that allows us to retrieve
18081808
// the argument type var.
1809-
for (auto argConstraint :
1810-
CS.getConstraintGraph()[typeVar].getConstraints()) {
1809+
auto &cg = CS.getConstraintGraph();
1810+
1811+
// FIXME: The type variable is not going to be part of the constraint graph
1812+
// at this point unless it was created at the outermost decision level;
1813+
// otherwise it has already been rolled back! Work around this by creating
1814+
// an empty node if one doesn't exist.
1815+
cg.addTypeVariable(typeVar);
1816+
1817+
for (auto argConstraint : cg[typeVar].getConstraints()) {
18111818
if (argConstraint->getKind() == ConstraintKind::ArgumentConversion &&
18121819
argConstraint->getFirstType()->getRValueType()->isEqual(typeVar)) {
18131820
if (auto argTV =

0 commit comments

Comments
 (0)