@@ -3626,8 +3626,10 @@ static bool generateWrappedPropertyTypeConstraints(
36263626 }
36273627
36283628 // The property type must be equal to the wrapped value type
3629- cs.addConstraint (ConstraintKind::Equal, propertyType, wrappedValueType,
3630- cs.getConstraintLocator (wrappedVar, LocatorPathElt::ContextualType ()));
3629+ cs.addConstraint (
3630+ ConstraintKind::Equal, propertyType, wrappedValueType,
3631+ cs.getConstraintLocator (
3632+ wrappedVar, LocatorPathElt::ContextualType (CTP_WrappedProperty)));
36313633 cs.setContextualType (wrappedVar, TypeLoc::withoutLoc (wrappedValueType),
36323634 CTP_WrappedProperty);
36333635 return false ;
@@ -3637,8 +3639,8 @@ static bool generateWrappedPropertyTypeConstraints(
36373639static bool generateInitPatternConstraints (
36383640 ConstraintSystem &cs, SolutionApplicationTarget target, Expr *initializer) {
36393641 auto pattern = target.getInitializationPattern ();
3640- auto locator =
3641- cs. getConstraintLocator ( initializer, LocatorPathElt::ContextualType ());
3642+ auto locator = cs. getConstraintLocator (
3643+ initializer, LocatorPathElt::ContextualType (CTP_Initialization ));
36423644 Type patternType = cs.generateConstraints (
36433645 pattern, locator, target.shouldBindPatternVarsOneWay (),
36443646 target.getInitializationPatternBindingDecl (),
@@ -3669,8 +3671,8 @@ generateForEachStmtConstraints(
36693671 bool isAsync = stmt->getAwaitLoc ().isValid ();
36703672
36713673 auto locator = cs.getConstraintLocator (sequence);
3672- auto contextualLocator =
3673- cs. getConstraintLocator ( sequence, LocatorPathElt::ContextualType ());
3674+ auto contextualLocator = cs. getConstraintLocator (
3675+ sequence, LocatorPathElt::ContextualType (CTP_ForEachStmt ));
36743676
36753677 // The expression type must conform to the Sequence protocol.
36763678 auto sequenceProto = TypeChecker::getProtocol (
@@ -3787,8 +3789,9 @@ bool ConstraintSystem::generateConstraints(
37873789 if (target.isOptionalSomePatternInit ()) {
37883790 assert (!target.getExprContextualType () &&
37893791 " some pattern cannot have contextual type pre-configured" );
3790- auto *convertTypeLocator =
3791- getConstraintLocator (expr, LocatorPathElt::ContextualType ());
3792+ auto *convertTypeLocator = getConstraintLocator (
3793+ expr, LocatorPathElt::ContextualType (
3794+ target.getExprContextualTypePurpose ()));
37923795 Type var = createTypeVariable (convertTypeLocator, TVO_CanBindToNoEscape);
37933796 target.setExprConversionType (TypeChecker::getOptionalType (expr->getLoc (), var));
37943797 }
@@ -3810,7 +3813,7 @@ bool ConstraintSystem::generateConstraints(
38103813 ContextualTypePurpose ctp = target.getExprContextualTypePurpose ();
38113814 bool isOpaqueReturnType = target.infersOpaqueReturnType ();
38123815 auto *convertTypeLocator =
3813- getConstraintLocator (expr, LocatorPathElt::ContextualType ());
3816+ getConstraintLocator (expr, LocatorPathElt::ContextualType (ctp ));
38143817
38153818 auto getLocator = [&](Type ty) -> ConstraintLocator * {
38163819 // If we have a placeholder originating from a PlaceholderTypeRepr,
@@ -3973,11 +3976,10 @@ bool ConstraintSystem::generateConstraints(StmtCondition condition,
39733976 return true ;
39743977 }
39753978
3976- addConstraint (ConstraintKind::Conversion,
3977- getType (condExpr),
3978- boolTy,
3979- getConstraintLocator (condExpr,
3980- LocatorPathElt::ContextualType ()));
3979+ addConstraint (
3980+ ConstraintKind::Conversion, getType (condExpr), boolTy,
3981+ getConstraintLocator (condExpr,
3982+ LocatorPathElt::ContextualType (CTP_Condition)));
39813983 continue ;
39823984 }
39833985
0 commit comments