Skip to content

Conversation

DougGregor
Copy link
Member

Wherever we have constraints that involve pattern matching, use the
PatternMatch locator element. Additionally, don't use the TupleElement
locator element for tuple patterns, because it violates assumptions used
for diagnostics.

The new test was crashing; now it has a terrible diagnostic for which I
need to think harder about a fix.

Wherever we have constraints that involve pattern matching, use the
PatternMatch locator element. Additionally, don't use the TupleElement
locator element for tuple patterns, because it violates assumptions used
for diagnostics.

The new test was crashing; now it has a terrible diagnostic for which I
need to think harder about a fix.
@DougGregor DougGregor requested a review from xedin March 6, 2020 07:07
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit b2facd0 into swiftlang:master Mar 6, 2020
@DougGregor DougGregor deleted the constraint-pattern-locators branch March 6, 2020 17:11
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested a couple of changes inline.

// Remove an optional from the object type.
if (externalPatternType) {
Type objVar = CS.createTypeVariable(
CS.getConstraintLocator(locator), TVO_CanBindToNoEscape);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case we should have locator with points to pattern and ends with OptionalPayload.

locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));

Type subPatternType =
getTypeForPattern(isPattern->getSubPattern(), locator, castType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think subPattern should have locator point to a sub-pattern used by a cast?

parentType = CS.openUnboundGenericType(parentType, locator);
parentType = CS.openUnboundGenericType(
parentType,
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use ParentType locator element for this transformation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later one where we add a member constraint I think it should either end on regular Member locator or a new one specific for patterns...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants