@@ -9205,17 +9205,21 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
92059205 dyn_cast<EnumElementPattern>(patternLoc->getPattern())) {
92069206 auto enumType = baseObjTy->getMetatypeInstanceType();
92079207
9208- // If the synthesis of ~= resulted in errors (i.e. broken stdlib)
9209- // that would be diagnosed inline, so let's just fall through and
9210- // let this situation be diagnosed as a missing member.
9211- auto hadErrors = inferEnumMemberThroughTildeEqualsOperator(
9208+ // Optional base type does not trigger `~=` synthesis, but it tries
9209+ // to find member on both `Optional` and its wrapped type.
9210+ if (!enumType->getOptionalObjectType()) {
9211+ // If the synthesis of ~= resulted in errors (i.e. broken stdlib)
9212+ // that would be diagnosed inline, so let's just fall through and
9213+ // let this situation be diagnosed as a missing member.
9214+ auto hadErrors = inferEnumMemberThroughTildeEqualsOperator(
92129215 *this, enumElement, enumType, memberTy, locator);
92139216
9214- // Let's consider current member constraint solved because it's
9215- // replaced by a new set of constraints that would resolve member
9216- // type.
9217- if (!hadErrors)
9218- return SolutionKind::Solved;
9217+ // Let's consider current member constraint solved because it's
9218+ // replaced by a new set of constraints that would resolve member
9219+ // type.
9220+ if (!hadErrors)
9221+ return SolutionKind::Solved;
9222+ }
92199223 }
92209224 }
92219225 }
0 commit comments