Skip to content

[cxx-interop] Allow function template instantiations with optional foreign reference types#89265

Open
patrykstefanski wants to merge 1 commit into
swiftlang:mainfrom
patrykstefanski:optional-frt-function-template-instantiation
Open

[cxx-interop] Allow function template instantiations with optional foreign reference types#89265
patrykstefanski wants to merge 1 commit into
swiftlang:mainfrom
patrykstefanski:optional-frt-function-template-instantiation

Conversation

@patrykstefanski
Copy link
Copy Markdown
Contributor

convertTemplateArgument only handled Optional<*Pointer<T>> types via classifyPointer(). For Optional<FRT>, it returned an empty QualType, failing the template instantiation. Add a case that converts Optional<FRT> to FRT* _Nullable, mirroring how the non-optional path produces FRT* _Nonnull via convertClangDecl.

rdar://177206923

…reign reference types

`convertTemplateArgument` only handled `Optional<*Pointer<T>>` types via
`classifyPointer()`. For `Optional<FRT>`, it returned an empty QualType,
failing the template instantiation. Add a case that converts
`Optional<FRT>` to `FRT* _Nullable`, mirroring how the non-optional path
produces `FRT* _Nonnull` via `convertClangDecl`.

rdar://177206923
// function re-imports with an optional return type. Otherwise, it would
// be re-imported as non-optional FRT.
if (argType->isForeignReferenceType()) {
return withCache([&]() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does withCache do?

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

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants