@@ -3612,8 +3612,10 @@ static bool generateWrappedPropertyTypeConstraints(
3612
3612
cs.addConstraint (ConstraintKind::Equal, wrapperType, initializerType, locator);
3613
3613
} else {
3614
3614
// The former wrappedValue type must be equal to the current wrapper type
3615
- cs.addConstraint (ConstraintKind::Equal, wrapperType, wrappedValueType,
3616
- cs.getConstraintLocator (locator, LocatorPathElt::ContextualType ()));
3615
+ cs.addConstraint (
3616
+ ConstraintKind::Equal, wrapperType, wrappedValueType,
3617
+ cs.getConstraintLocator (locator, LocatorPathElt::ContextualType (
3618
+ CTP_ComposedPropertyWrapper)));
3617
3619
cs.setContextualType (typeExpr, TypeLoc::withoutLoc (wrappedValueType),
3618
3620
CTP_ComposedPropertyWrapper);
3619
3621
}
@@ -3623,8 +3625,10 @@ static bool generateWrappedPropertyTypeConstraints(
3623
3625
}
3624
3626
3625
3627
// The property type must be equal to the wrapped value type
3626
- cs.addConstraint (ConstraintKind::Equal, propertyType, wrappedValueType,
3627
- cs.getConstraintLocator (wrappedVar, LocatorPathElt::ContextualType ()));
3628
+ cs.addConstraint (
3629
+ ConstraintKind::Equal, propertyType, wrappedValueType,
3630
+ cs.getConstraintLocator (
3631
+ wrappedVar, LocatorPathElt::ContextualType (CTP_WrappedProperty)));
3628
3632
cs.setContextualType (wrappedVar, TypeLoc::withoutLoc (wrappedValueType),
3629
3633
CTP_WrappedProperty);
3630
3634
return false ;
@@ -3634,8 +3638,8 @@ static bool generateWrappedPropertyTypeConstraints(
3634
3638
static bool generateInitPatternConstraints (
3635
3639
ConstraintSystem &cs, SolutionApplicationTarget target, Expr *initializer) {
3636
3640
auto pattern = target.getInitializationPattern ();
3637
- auto locator =
3638
- cs. getConstraintLocator ( initializer, LocatorPathElt::ContextualType ());
3641
+ auto locator = cs. getConstraintLocator (
3642
+ initializer, LocatorPathElt::ContextualType (CTP_Initialization ));
3639
3643
Type patternType = cs.generateConstraints (
3640
3644
pattern, locator, target.shouldBindPatternVarsOneWay (),
3641
3645
target.getInitializationPatternBindingDecl (),
@@ -3666,8 +3670,8 @@ generateForEachStmtConstraints(
3666
3670
bool isAsync = stmt->getAwaitLoc ().isValid ();
3667
3671
3668
3672
auto locator = cs.getConstraintLocator (sequence);
3669
- auto contextualLocator =
3670
- cs. getConstraintLocator ( sequence, LocatorPathElt::ContextualType ());
3673
+ auto contextualLocator = cs. getConstraintLocator (
3674
+ sequence, LocatorPathElt::ContextualType (CTP_ForEachStmt ));
3671
3675
3672
3676
// The expression type must conform to the Sequence protocol.
3673
3677
auto sequenceProto = TypeChecker::getProtocol (
@@ -3784,8 +3788,9 @@ bool ConstraintSystem::generateConstraints(
3784
3788
if (target.isOptionalSomePatternInit ()) {
3785
3789
assert (!target.getExprContextualType () &&
3786
3790
" some pattern cannot have contextual type pre-configured" );
3787
- auto *convertTypeLocator =
3788
- getConstraintLocator (expr, LocatorPathElt::ContextualType ());
3791
+ auto *convertTypeLocator = getConstraintLocator (
3792
+ expr, LocatorPathElt::ContextualType (
3793
+ target.getExprContextualTypePurpose ()));
3789
3794
Type var = createTypeVariable (convertTypeLocator, TVO_CanBindToNoEscape);
3790
3795
target.setExprConversionType (TypeChecker::getOptionalType (expr->getLoc (), var));
3791
3796
}
@@ -3807,7 +3812,7 @@ bool ConstraintSystem::generateConstraints(
3807
3812
ContextualTypePurpose ctp = target.getExprContextualTypePurpose ();
3808
3813
bool isOpaqueReturnType = target.infersOpaqueReturnType ();
3809
3814
auto *convertTypeLocator =
3810
- getConstraintLocator (expr, LocatorPathElt::ContextualType ());
3815
+ getConstraintLocator (expr, LocatorPathElt::ContextualType (ctp ));
3811
3816
3812
3817
auto getLocator = [&](Type ty) -> ConstraintLocator * {
3813
3818
// If we have a placeholder originating from a PlaceholderTypeRepr,
@@ -3970,11 +3975,10 @@ bool ConstraintSystem::generateConstraints(StmtCondition condition,
3970
3975
return true ;
3971
3976
}
3972
3977
3973
- addConstraint (ConstraintKind::Conversion,
3974
- getType (condExpr),
3975
- boolTy,
3976
- getConstraintLocator (condExpr,
3977
- LocatorPathElt::ContextualType ()));
3978
+ addConstraint (
3979
+ ConstraintKind::Conversion, getType (condExpr), boolTy,
3980
+ getConstraintLocator (condExpr,
3981
+ LocatorPathElt::ContextualType (CTP_Condition)));
3978
3982
continue ;
3979
3983
}
3980
3984
0 commit comments