Skip to content

[cxx-interop] Make __convertToBool() available but deprecated#89258

Open
j-hui wants to merge 2 commits into
swiftlang:mainfrom
j-hui:convert-to-bool-depr
Open

[cxx-interop] Make __convertToBool() available but deprecated#89258
j-hui wants to merge 2 commits into
swiftlang:mainfrom
j-hui:convert-to-bool-depr

Conversation

@j-hui
Copy link
Copy Markdown
Contributor

@j-hui j-hui commented May 19, 2026

In 9c35230 I made __convertToBool()
an unavailable function following the pattern of other synthesized
underlying functions. This was actually not good because others were
relying on this as a workaround for when CxxBool conformance doesn't
kick in.

In this patch, I bring back __convertToBool() and mark it as deprecated
rather than as unavailable. This allows the user to call it but warns
them against doing so while we iron out the kinks with CxxBool.

rdar://177377260

@j-hui
Copy link
Copy Markdown
Contributor Author

j-hui commented May 19, 2026

@swift-ci please smoke test

Copy link
Copy Markdown
Member

@hnrklssn hnrklssn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the changes to .pointee and .successor?

Copy link
Copy Markdown
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good. I had one idea but I am not too attached to it, also fine as is.

CXXOverload overload,
NominalTypeDecl *Struct,
StringRef unavailabilityMsg) {
static FuncDecl *importUnderlyingFunction(ClangImporter::Implementation &Impl,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could have an enum parameter whether it needs to be unavailable or deprecated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered doing that but just felt that this was simpler, since adding the unavailability attr was a one-liner, and we were doing other modifications at the call sites of this helper anyway.

That said, I'm happy to do the enum if you feel strongly about this!

@j-hui
Copy link
Copy Markdown
Contributor Author

j-hui commented May 19, 2026

Do we need the changes to .pointee and .successor?

Yeah, those + __convertToBool all used to share a helper function that would do the importing and then automatically add the unavailability attr.

I ripped out the unavailability attr part so I had to push that into all call sites of in .pointee and .successor.

Also, while doing this, I spotted a typo for the .successor unavailability message 😨 So I fixed that while I was at it.

@j-hui
Copy link
Copy Markdown
Contributor Author

j-hui commented May 19, 2026

Collided with #89253, rebasing

@j-hui j-hui force-pushed the convert-to-bool-depr branch from 88c0e20 to d00d88e Compare May 19, 2026 20:19
@j-hui
Copy link
Copy Markdown
Contributor Author

j-hui commented May 19, 2026

@swift-ci please smoke test

j-hui added 2 commits May 19, 2026 17:12
These flags don't make any difference so this is completely unnecessary.
In 9c35230 I made __convertToBool()
an unavailable function following the pattern of other synthesized
underlying functions. This was actually not good because others were
relying on this as a workaround for when CxxBool conformance doesn't
kick in.

In this patch, I bring back __convertToBool() and mark it as deprecated
rather than as unavailable. This allows the user to call it but warns
them against doing so while we iron out the kinks with CxxBool.

rdar://177377260
@j-hui j-hui force-pushed the convert-to-bool-depr branch from d00d88e to 648427b Compare May 20, 2026 00:12
@j-hui
Copy link
Copy Markdown
Contributor Author

j-hui commented May 20, 2026

@swift-ci Please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants