@@ -9216,17 +9216,21 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
9216
9216
dyn_cast<EnumElementPattern>(patternLoc->getPattern())) {
9217
9217
auto enumType = baseObjTy->getMetatypeInstanceType();
9218
9218
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(
9223
9226
*this, enumElement, enumType, memberTy, locator);
9224
9227
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
+ }
9230
9234
}
9231
9235
}
9232
9236
}
0 commit comments