@@ -2366,10 +2366,11 @@ namespace {
2366
2366
// Remove an optional from the object type.
2367
2367
if (externalPatternType) {
2368
2368
Type objVar = CS.createTypeVariable (
2369
- CS.getConstraintLocator (locator), TVO_CanBindToNoEscape);
2369
+ CS.getConstraintLocator (
2370
+ locator.withPathElement (ConstraintLocator::OptionalPayload)),
2371
+ TVO_CanBindToNoEscape);
2370
2372
CS.addConstraint (
2371
- ConstraintKind::OptionalObject, externalPatternType,
2372
- objVar,
2373
+ ConstraintKind::OptionalObject, externalPatternType, objVar,
2373
2374
locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2374
2375
2375
2376
externalPatternType = objVar;
@@ -2392,9 +2393,11 @@ namespace {
2392
2393
castType,
2393
2394
locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2394
2395
2395
- Type subPatternType =
2396
- getTypeForPattern (isPattern->getSubPattern (), locator, castType,
2397
- bindPatternVarsOneWay);
2396
+ auto *subPattern = isPattern->getSubPattern ();
2397
+ Type subPatternType = getTypeForPattern (
2398
+ subPattern,
2399
+ locator.withPathElement (LocatorPathElt::PatternMatch (subPattern)),
2400
+ castType, bindPatternVarsOneWay);
2398
2401
2399
2402
// Make sure we can cast from the subpattern type to the type we're
2400
2403
// checking; if it's impossible, fail.
@@ -2427,16 +2430,20 @@ namespace {
2427
2430
// Resolve the parent type.
2428
2431
Type parentType =
2429
2432
resolveTypeReferenceInExpression (enumPattern->getParentType ());
2433
+
2430
2434
parentType = CS.openUnboundGenericType (
2431
- parentType,
2432
- locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2435
+ parentType, CS.getConstraintLocator (
2436
+ locator, {LocatorPathElt::PatternMatch (pattern),
2437
+ ConstraintLocator::ParentType}));
2433
2438
2434
2439
// Perform member lookup into the parent's metatype.
2435
2440
Type parentMetaType = MetatypeType::get (parentType);
2436
2441
CS.addValueMemberConstraint (
2437
2442
parentMetaType, enumPattern->getName (), memberType, CurDC,
2438
- functionRefKind, { },
2439
- locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2443
+ functionRefKind, {},
2444
+ CS.getConstraintLocator (locator,
2445
+ {LocatorPathElt::PatternMatch (pattern),
2446
+ ConstraintLocator::Member}));
2440
2447
2441
2448
// Parent type needs to be convertible to the pattern type; this
2442
2449
// accounts for cases where the pattern type is existential.
0 commit comments