Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[interop] FRT doesn't allow retain/release with templated functions #61620

Open
hyp opened this issue Oct 18, 2022 · 2 comments
Open

[interop] FRT doesn't allow retain/release with templated functions #61620

hyp opened this issue Oct 18, 2022 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ compiler The Swift compiler itself

Comments

@hyp
Copy link
Contributor

hyp commented Oct 18, 2022

I would like to import an FRT that uses a templated retain/release function. This is currently not allowed:

template <class P>
void retain(P* ptr) {
	ptr->retain();
}

template <class P>
void release(P* ptr) {
	ptr->release();
}

#define SWIFT_CXX_REF   \
    __attribute__((swift_attr("import_as_ref")))   \
    __attribute__((swift_attr("retain:retain")))   \
    __attribute__((swift_attr("release:release")))

class SWIFT_CXX_REF Ref { };

output:

error: cannot find retain function 'retain' for reference type 'Ref'
@hyp hyp added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ labels Oct 18, 2022
@ktoso
Copy link
Contributor

ktoso commented Nov 16, 2022

rdar://102395866

@hyp
Copy link
Contributor Author

hyp commented Nov 17, 2022

Another example that we should support:

template <class P>
void retain(P* ptr) {
	ptr->retain();
}

template <class P>
void release(P* ptr) {
	ptr->release();
}

#define SWIFT_CXX_REF   \
    __attribute__((swift_attr("import_as_ref")))   \
    __attribute__((swift_attr("retain:retain")))   \
    __attribute__((swift_attr("release:release")))

template<class P>
class SWIFT_CXX_REF TemplateRef { };

using ConcreteRef = TemplateRef<int>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ compiler The Swift compiler itself
Projects
None yet
Development

No branches or pull requests

4 participants