Improved handling of mixed lvalues & rvalues in tuple exprs

My previous commit here didn’t work correctly for nested tuples, both
because it didn’t recurse into them to propagate access kind correctly
and because an outer TupleIndex overload (when indexing into the nested
tuple) could still be expecting an lvalue type.

This fix is much better. ConstraintSystem::resolveOverload now
correctly always expects rvalue types from rvalue tuples. And during
applyMemberRefExpr, if the overload expects an rvalue but the tuple
contains lvalues, coerceToType() correctly does any recursive munging
of the tuple expr required.
This commit is contained in:
gregomni
2016-01-31 09:14:16 -08:00
parent e0c028db74
commit 37d05ea0dc
3 changed files with 14 additions and 28 deletions

View File

@@ -1385,7 +1385,7 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
} else {
// When the base is a tuple rvalue, the member is always an rvalue.
auto tuple = choice.getBaseType()->castTo<TupleType>();
refType = tuple->getElementType(choice.getTupleIndex());
refType = tuple->getElementType(choice.getTupleIndex())->getRValueType();
}
break;
}