@@ -9216,17 +9216,21 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
92169216 dyn_cast<EnumElementPattern>(patternLoc->getPattern())) {
92179217 auto enumType = baseObjTy->getMetatypeInstanceType();
92189218
9219- // If the synthesis of ~= resulted in errors (i.e. broken stdlib)
9220- // that would be diagnosed inline, so let's just fall through and
9221- // let this situation be diagnosed as a missing member.
9222- auto hadErrors = inferEnumMemberThroughTildeEqualsOperator(
9219+ // Optional base type does not trigger `~=` synthesis, but it tries
9220+ // to find member on both `Optional` and its wrapped type.
9221+ if (!enumType->getOptionalObjectType()) {
9222+ // If the synthesis of ~= resulted in errors (i.e. broken stdlib)
9223+ // that would be diagnosed inline, so let's just fall through and
9224+ // let this situation be diagnosed as a missing member.
9225+ auto hadErrors = inferEnumMemberThroughTildeEqualsOperator(
92239226 *this, enumElement, enumType, memberTy, locator);
92249227
9225- // Let's consider current member constraint solved because it's
9226- // replaced by a new set of constraints that would resolve member
9227- // type.
9228- if (!hadErrors)
9229- return SolutionKind::Solved;
9228+ // Let's consider current member constraint solved because it's
9229+ // replaced by a new set of constraints that would resolve member
9230+ // type.
9231+ if (!hadErrors)
9232+ return SolutionKind::Solved;
9233+ }
92309234 }
92319235 }
92329236 }
0 commit comments