Skip to content

Conversation

@fahadnayyar
Copy link
Contributor

Adding a sentence in the documentation thatthe foreign-reference annotations are now propagated to inherited C++ types

@fahadnayyar fahadnayyar marked this pull request as ready for review June 10, 2025 22:01
@Xazax-hun
Copy link
Contributor

cc @egorzhdan

@fahadnayyar
Copy link
Contributor Author

CC: @j-hui
if you can also please take a look!

@fahadnayyar
Copy link
Contributor Author

CC: @ravikandhadai

@fahadnayyar
Copy link
Contributor Author

This patch needs 2 important things to be included:

  • behaviour in case of multiple inheritance.
  • Clarification about immortal references.


When a C++ type inherits from a `SWIFT_SHARED_REFERENCE` base type, the Swift compiler automatically infers `SWIFT_SHARED_REFERENCE` annotation for the derived type.
The derived type also gets imported as a reference type, and uses the same `retain` and `release` functions as its base class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@j-hui I changed some text based on your suggestions but added my flavor as well. How does it look now?

// `object` will be released here.
```

### Inference of Shared Reference behaviour in Derived Types
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: ### -> ####

@fahadnayyar
Copy link
Contributor Author

including this in PR-1106

@fahadnayyar fahadnayyar closed this Jul 8, 2025
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.

4 participants