Skip to content

Commit b7bdda4

Browse files
committed
[CSBindings] Infer l-value type for object of ForceValueExpr only if var allows it
Otherwise l-value is going to get stripped from the type by `addPotentialBinding` and we'd end up with duplicate bindings.
1 parent e301b19 commit b7bdda4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,8 @@ bool ConstraintSystem::PotentialBindings::infer(
10131013
// type from context e.g. parameter type of a function call),
10141014
// we need to test type with and without l-value after
10151015
// delaying bindings for as long as possible.
1016-
if (isExpr<ForceValueExpr>(anchor) && !type->is<LValueType>()) {
1016+
if (isExpr<ForceValueExpr>(anchor) &&
1017+
TypeVar->getImpl().canBindToLValue() && !type->is<LValueType>()) {
10171018
addPotentialBinding(binding->withType(LValueType::get(type)));
10181019
DelayedBy.push_back(constraint);
10191020
}

0 commit comments

Comments
 (0)