Skip to content

Commit 94ffe9a

Browse files
authored
Merge pull request swiftlang#30336 from xedin/adjust-pattern-locators
[CSGen] Clarify locators for some of the patterns
2 parents 4ac3593 + f1f3b60 commit 94ffe9a

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

lib/Sema/CSGen.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,10 +2366,11 @@ namespace {
23662366
// Remove an optional from the object type.
23672367
if (externalPatternType) {
23682368
Type objVar = CS.createTypeVariable(
2369-
CS.getConstraintLocator(locator), TVO_CanBindToNoEscape);
2369+
CS.getConstraintLocator(
2370+
locator.withPathElement(ConstraintLocator::OptionalPayload)),
2371+
TVO_CanBindToNoEscape);
23702372
CS.addConstraint(
2371-
ConstraintKind::OptionalObject, externalPatternType,
2372-
objVar,
2373+
ConstraintKind::OptionalObject, externalPatternType, objVar,
23732374
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
23742375

23752376
externalPatternType = objVar;
@@ -2392,9 +2393,11 @@ namespace {
23922393
castType,
23932394
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
23942395

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);
23982401

23992402
// Make sure we can cast from the subpattern type to the type we're
24002403
// checking; if it's impossible, fail.
@@ -2427,16 +2430,20 @@ namespace {
24272430
// Resolve the parent type.
24282431
Type parentType =
24292432
resolveTypeReferenceInExpression(enumPattern->getParentType());
2433+
24302434
parentType = CS.openUnboundGenericType(
2431-
parentType,
2432-
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
2435+
parentType, CS.getConstraintLocator(
2436+
locator, {LocatorPathElt::PatternMatch(pattern),
2437+
ConstraintLocator::ParentType}));
24332438

24342439
// Perform member lookup into the parent's metatype.
24352440
Type parentMetaType = MetatypeType::get(parentType);
24362441
CS.addValueMemberConstraint(
24372442
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}));
24402447

24412448
// Parent type needs to be convertible to the pattern type; this
24422449
// accounts for cases where the pattern type is existential.

0 commit comments

Comments
 (0)