Skip to content

Commit 1c11fcd

Browse files
committed
Don't lie about the intermediate result type when synthesizing a call to a
function that returns UnsafeMutablePointer.
1 parent 91a3abc commit 1c11fcd

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5494,19 +5494,18 @@ synthesizeBaseClassFieldGetterOrAddressGetterBody(AbstractFunctionDecl *afd,
54945494
auto *baseMemberCallExpr =
54955495
CallExpr::createImplicit(ctx, baseMemberDotCallExpr, argumentList);
54965496
Type resultType = baseGetterMethod->getResultInterfaceType();
5497-
if (kind == AccessorKind::Address && resultType->isUnsafeMutablePointer()) {
5498-
resultType = getterDecl->getResultInterfaceType();
5499-
}
55005497
baseMemberCallExpr->setType(resultType);
55015498
baseMemberCallExpr->setThrows(nullptr);
55025499

55035500
Expr *returnExpr = baseMemberCallExpr;
55045501
// Cast an 'address' result from a mutable pointer if needed.
55055502
if (kind == AccessorKind::Address &&
5506-
baseGetterMethod->getResultInterfaceType()->isUnsafeMutablePointer())
5503+
baseGetterMethod->getResultInterfaceType()->isUnsafeMutablePointer()) {
5504+
auto finalResultType = getterDecl->getResultInterfaceType();
55075505
returnExpr = SwiftDeclSynthesizer::synthesizeReturnReinterpretCast(
5508-
ctx, baseGetterMethod->getResultInterfaceType(), resultType,
5506+
ctx, baseGetterMethod->getResultInterfaceType(), finalResultType,
55095507
returnExpr);
5508+
}
55105509

55115510
auto *returnStmt = ReturnStmt::createImplicit(ctx, returnExpr);
55125511

0 commit comments

Comments
 (0)