@@ -14155,7 +14155,48 @@ ConstraintSystem::SolutionKind
1415514155ConstraintSystem::simplifyLValueObjectConstraint(
1415614156 Type type1, Type type2, TypeMatchOptions flags,
1415714157 ConstraintLocatorBuilder locator) {
14158- return SolutionKind::Error;
14158+ auto lvalueTy = simplifyType(type1);
14159+
14160+ auto formUnsolved = [&]() {
14161+ // If we're supposed to generate constraints, do so.
14162+ if (flags.contains(TMF_GenerateConstraints)) {
14163+ auto *lvalueObject =
14164+ Constraint::create(*this, ConstraintKind::LValueObject,
14165+ type1, type2, getConstraintLocator(locator));
14166+
14167+ addUnsolvedConstraint(lvalueObject);
14168+ return SolutionKind::Solved;
14169+ }
14170+
14171+ return SolutionKind::Unsolved;
14172+ };
14173+
14174+ auto isOrCanBeLValueType = [](Type type) {
14175+ if (auto *typeVar = type->getAs<TypeVariableType>()) {
14176+ return typeVar->getImpl().canBindToLValue();
14177+ }
14178+ return type->is<LValueType>();
14179+ };
14180+
14181+ if (!isOrCanBeLValueType(lvalueTy)) {
14182+ if (!shouldAttemptFixes())
14183+ return SolutionKind::Error;
14184+
14185+ if (recordFix(
14186+ TreatRValueAsLValue::create(*this, getConstraintLocator(locator))))
14187+ return SolutionKind::Error;
14188+
14189+ lvalueTy = LValueType::get(lvalueTy);
14190+ }
14191+
14192+ if (lvalueTy->isTypeVariableOrMember())
14193+ return formUnsolved();
14194+
14195+ // TODO: This operation deserves its own locator just like OptionalObject.
14196+ addConstraint(ConstraintKind::Equal,
14197+ lvalueTy->castTo<LValueType>()->getObjectType(), type2,
14198+ getConstraintLocator(locator));
14199+ return SolutionKind::Solved;
1415914200}
1416014201
1416114202static llvm::PointerIntPair<Type, 3, unsigned>
0 commit comments