Skip to content

Commit 26f0a80

Browse files
committed
[Sema] Transfer contextual type info when we inject UnresolvedMemberChainResultExpr
If we create an UnresolvedMemberChainResultExpr at the top level, we may end up losing contextual type information that was already attached to the end of the chain. To avoid this, we fetch any existing contextual type info and transfer it to the newly injected expression.
1 parent ed94131 commit 26f0a80

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/Sema/CSGen.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3847,8 +3847,14 @@ namespace {
38473847
if (auto *UME = getUnresolvedMemberChainBase(expr)) {
38483848
CG.setUnresolvedChainBase(expr, UME);
38493849
if (!parent || !isa<UnresolvedMemberChainResultExpr>(parent)) {
3850-
auto &context = CG.getConstraintSystem().getASTContext();
3850+
auto &cs = CG.getConstraintSystem();
3851+
auto &context = cs.getASTContext();
3852+
auto typeInfo = cs.getContextualTypeInfo(expr);
38513853
expr = new (context) UnresolvedMemberChainResultExpr(expr);
3854+
if (typeInfo) {
3855+
cs.setContextualType(expr, (*typeInfo).typeLoc,
3856+
(*typeInfo).purpose);
3857+
}
38523858
}
38533859
}
38543860
}

0 commit comments

Comments
 (0)