@@ -9205,17 +9205,21 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
9205
9205
dyn_cast<EnumElementPattern>(patternLoc->getPattern())) {
9206
9206
auto enumType = baseObjTy->getMetatypeInstanceType();
9207
9207
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(
9212
9215
*this, enumElement, enumType, memberTy, locator);
9213
9216
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
+ }
9219
9223
}
9220
9224
}
9221
9225
}
0 commit comments