@@ -2342,15 +2342,17 @@ namespace {
2342
2342
2343
2343
Type openedType = CS.openUnboundGenericType (type, locator);
2344
2344
2345
+ auto *subPattern = cast<TypedPattern>(pattern)->getSubPattern ();
2345
2346
// Determine the subpattern type. It will be convertible to the
2346
2347
// ascribed type.
2347
- Type subPatternType =
2348
- getTypeForPattern (
2349
- cast<TypedPattern>(pattern)->getSubPattern (), locator,
2350
- Type (), bindPatternVarsOneWay);
2348
+ Type subPatternType = getTypeForPattern (
2349
+ subPattern,
2350
+ locator.withPathElement (LocatorPathElt::PatternMatch (subPattern)),
2351
+ Type (), bindPatternVarsOneWay);
2352
+
2351
2353
CS.addConstraint (
2352
2354
ConstraintKind::Conversion, subPatternType, openedType,
2353
- locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2355
+ locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2354
2356
return setType (openedType);
2355
2357
}
2356
2358
@@ -2385,11 +2387,11 @@ namespace {
2385
2387
if (!externalEltTypes.empty ())
2386
2388
externalEltType = externalEltTypes[i].getPlainType ();
2387
2389
2390
+ auto *eltPattern = tupleElt.getPattern ();
2388
2391
Type eltTy = getTypeForPattern (
2389
- tupleElt.getPattern (),
2390
- locator,
2391
- externalEltType,
2392
- bindPatternVarsOneWay);
2392
+ eltPattern,
2393
+ locator.withPathElement (LocatorPathElt::PatternMatch (eltPattern)),
2394
+ externalEltType, bindPatternVarsOneWay);
2393
2395
tupleTypeElts.push_back (TupleTypeElt (eltTy, tupleElt.getLabel ()));
2394
2396
}
2395
2397
@@ -2410,9 +2412,11 @@ namespace {
2410
2412
externalPatternType = objVar;
2411
2413
}
2412
2414
2415
+ auto *subPattern = cast<OptionalSomePattern>(pattern)->getSubPattern ();
2413
2416
// The subpattern must have optional type.
2414
2417
Type subPatternType = getTypeForPattern (
2415
- cast<OptionalSomePattern>(pattern)->getSubPattern (), locator,
2418
+ subPattern,
2419
+ locator.withPathElement (LocatorPathElt::PatternMatch (subPattern)),
2416
2420
externalPatternType, bindPatternVarsOneWay);
2417
2421
2418
2422
return setType (OptionalType::get (subPatternType));
0 commit comments