@@ -503,43 +503,31 @@ Type ConstraintSystem::getUnopenedTypeOfReference(
503503 VarDecl *value, Type baseType, DeclContext *UseDC,
504504 ConstraintLocator *locator, bool wantInterfaceType,
505505 bool adjustForPreconcurrency) {
506- return ConstraintSystem::getUnopenedTypeOfReference (
507- value, baseType, UseDC,
508- [&](VarDecl *var) -> Type {
509- if (Type type = getTypeIfAvailable (var))
510- return type;
511-
512- if (!var->hasInterfaceType ()) {
513- return ErrorType::get (getASTContext ());
514- }
515-
516- return wantInterfaceType ? var->getInterfaceType () : var->getTypeInContext ();
517- },
518- locator, wantInterfaceType, adjustForPreconcurrency,
519- GetClosureType{*this },
520- ClosureIsolatedByPreconcurrency{*this },
521- IsInLeftHandSideOfAssignment{*this });
522- }
506+ Type requestedType;
507+ if (Type type = getTypeIfAvailable (value)) {
508+ requestedType = type;
509+ } else if (!value->hasInterfaceType ()) {
510+ requestedType = ErrorType::get (getASTContext ());
511+ } else {
512+ requestedType = (wantInterfaceType
513+ ? value->getInterfaceType ()
514+ : value->getTypeInContext ());
515+ }
523516
524- Type ConstraintSystem::getUnopenedTypeOfReference (
525- VarDecl *value, Type baseType, DeclContext *UseDC,
526- llvm::function_ref<Type(VarDecl *)> getType,
527- ConstraintLocator *locator,
528- bool wantInterfaceType, bool adjustForPreconcurrency,
529- llvm::function_ref<Type(const AbstractClosureExpr *)> getClosureType,
530- llvm::function_ref<bool(const ClosureExpr *)> isolatedByPreconcurrency,
531- llvm::function_ref<bool(Expr *)> isAssignTarget) {
532- Type requestedType =
533- getType (value)->getWithoutSpecifierType ()->getReferenceStorageReferent ();
517+ requestedType =
518+ requestedType->getWithoutSpecifierType ()->getReferenceStorageReferent ();
534519
535520 // Strip pack expansion types off of pack references.
536521 if (auto *expansion = requestedType->getAs <PackExpansionType>())
537522 requestedType = expansion->getPatternType ();
538523
539524 // Adjust the type for concurrency if requested.
540- if (adjustForPreconcurrency)
525+ if (adjustForPreconcurrency) {
541526 requestedType = adjustVarTypeForConcurrency (
542- requestedType, value, UseDC, getClosureType, isolatedByPreconcurrency);
527+ requestedType, value, UseDC,
528+ GetClosureType{*this },
529+ ClosureIsolatedByPreconcurrency{*this });
530+ }
543531
544532 // If we're dealing with contextual types, and we referenced this type from
545533 // a different context, map the type.
@@ -553,7 +541,8 @@ Type ConstraintSystem::getUnopenedTypeOfReference(
553541
554542 // Qualify storage declarations with an lvalue when appropriate.
555543 // Otherwise, they yield rvalues (and the access must be a load).
556- if (doesStorageProduceLValue (value, baseType, UseDC, isAssignTarget,
544+ if (doesStorageProduceLValue (value, baseType, UseDC,
545+ IsInLeftHandSideOfAssignment{*this },
557546 locator) &&
558547 !requestedType->hasError ()) {
559548 return LValueType::get (requestedType);
0 commit comments