mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #42146 from xedin/rdar-91145060
[ConstraintSystem] Cache types of `~=` components
This commit is contained in:
@@ -8774,7 +8774,7 @@ ExprWalker::rewriteTarget(SolutionApplicationTarget target) {
|
||||
if (auto *enumElement = dyn_cast<EnumElementPattern>(info.pattern)) {
|
||||
if (auto target = cs.getSolutionApplicationTarget(enumElement)) {
|
||||
auto *EP = target->getExprPattern();
|
||||
auto enumType = solution.simplifyType(EP->getType());
|
||||
auto enumType = solution.getResolvedType(EP);
|
||||
|
||||
auto *matchCall = target->getAsExpr();
|
||||
|
||||
|
||||
@@ -8944,6 +8944,9 @@ static bool inferEnumMemberThroughTildeEqualsOperator(
|
||||
|
||||
std::tie(matchVar, matchCall) = *tildeEqualsApplication;
|
||||
|
||||
cs.setType(matchVar, enumTy);
|
||||
cs.setType(EP, enumTy);
|
||||
|
||||
// result of ~= operator is always a `Bool`.
|
||||
auto target = SolutionApplicationTarget::forExprPattern(
|
||||
matchCall, DC, EP, ctx.getBoolDecl()->getDeclaredInterfaceType());
|
||||
@@ -8972,7 +8975,6 @@ static bool inferEnumMemberThroughTildeEqualsOperator(
|
||||
// Store the $match variable and binary expression for solution application.
|
||||
EP->setMatchVar(matchVar);
|
||||
EP->setMatchExpr(matchCall);
|
||||
EP->setType(enumTy);
|
||||
|
||||
cs.setSolutionApplicationTarget(pattern, target);
|
||||
|
||||
|
||||
@@ -880,6 +880,8 @@ bool TypeChecker::typeCheckExprPattern(ExprPattern *EP, DeclContext *DC,
|
||||
|
||||
std::tie(matchVar, matchCall) = *tildeEqualsApplication;
|
||||
|
||||
matchVar->setInterfaceType(rhsType->mapTypeOutOfContext());
|
||||
|
||||
// Result of `~=` should always be a boolean.
|
||||
auto contextualTy = Context.getBoolDecl()->getDeclaredInterfaceType();
|
||||
auto target = SolutionApplicationTarget::forExprPattern(matchCall, DC, EP,
|
||||
@@ -908,7 +910,6 @@ TypeChecker::synthesizeTildeEqualsOperatorApplication(ExprPattern *EP,
|
||||
auto *matchVar =
|
||||
new (Context) VarDecl(/*IsStatic*/ false, VarDecl::Introducer::Let,
|
||||
EP->getLoc(), Context.Id_PatternMatchVar, DC);
|
||||
matchVar->setInterfaceType(enumType->mapTypeOutOfContext());
|
||||
|
||||
matchVar->setImplicit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user