@@ -2783,6 +2783,9 @@ namespace {
27832783 if (dyn_cast_or_null<TuplePattern>(enumPattern->getSubPattern ()))
27842784 functionRefKind = FunctionRefKind::Compound;
27852785
2786+ auto patternLocator =
2787+ locator.withPathElement (LocatorPathElt::PatternMatch (pattern));
2788+
27862789 if (enumPattern->getParentType () || enumPattern->getParentTypeRepr ()) {
27872790 // Resolve the parent type.
27882791 const auto parentType = [&] {
@@ -2810,25 +2813,23 @@ namespace {
28102813
28112814 // Perform member lookup into the parent's metatype.
28122815 Type parentMetaType = MetatypeType::get (parentType);
2813- CS.addValueMemberConstraint (
2814- parentMetaType, enumPattern->getName (), memberType, CurDC,
2815- functionRefKind, {},
2816- CS.getConstraintLocator (locator,
2817- LocatorPathElt::PatternMatch (pattern)));
2816+ CS.addValueMemberConstraint (parentMetaType, enumPattern->getName (),
2817+ memberType, CurDC, functionRefKind, {},
2818+ patternLocator);
28182819
28192820 // Parent type needs to be convertible to the pattern type; this
28202821 // accounts for cases where the pattern type is existential.
28212822 CS.addConstraint (
28222823 ConstraintKind::Conversion, parentType, patternType,
2823- locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2824+ patternLocator.withPathElement (
2825+ ConstraintLocator::EnumPatternImplicitCastMatch));
28242826
28252827 baseType = parentType;
28262828 } else {
28272829 // Use the pattern type for member lookup.
28282830 CS.addUnresolvedValueMemberConstraint (
28292831 MetatypeType::get (patternType), enumPattern->getName (),
2830- memberType, CurDC, functionRefKind,
2831- locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2832+ memberType, CurDC, functionRefKind, patternLocator);
28322833
28332834 baseType = patternType;
28342835 }
@@ -2865,13 +2866,11 @@ namespace {
28652866 // NOTE: The order here is important! Pattern matching equality is
28662867 // not symmetric (we need to fix that either by using a different
28672868 // constraint, or actually making it symmetric).
2868- CS.addConstraint (
2869- ConstraintKind::Equal, functionType, memberType,
2870- locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2869+ CS.addConstraint (ConstraintKind::Equal, functionType, memberType,
2870+ patternLocator);
28712871
2872- CS.addConstraint (
2873- ConstraintKind::Conversion, outputType, baseType,
2874- locator.withPathElement (LocatorPathElt::PatternMatch (pattern)));
2872+ CS.addConstraint (ConstraintKind::Conversion, outputType, baseType,
2873+ patternLocator);
28752874 }
28762875
28772876 return setType (patternType);
0 commit comments