Skip to content

Conversation

@susmonteiro
Copy link
Contributor

This adds support for reading from and modifying subscripts of non-copyable types, including the subscript of a non-copyable std::vector.

rdar://156698253

@susmonteiro susmonteiro added the c++ interop Feature: Interoperability with C++ label Dec 18, 2025
@susmonteiro
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
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.

LG, thanks!

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

Thank you! Just a couple of small questions.

for (auto ctor : decl->ctors()) {
if (ctor->isCopyConstructor() &&
// FIXME: Support default arguments (rdar://142414553)
// FIXME: Support default arguments
Copy link
Contributor

Choose a reason for hiding this comment

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

Accidental change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doug noticed these radars numbers and asked for them to be removed. Since this is a small change, in a file that this patch touches, I thought it would be reasonable to do it here instead of creating a separate patch just for this. Would you prefer me to do it in a separate patch?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to keep it out of this PR, since you're not modifying this code part here.

If you'd like to remove there rdar links, could you please file GitHub issues and link to them in the comments instead? That way someone encountering this FIXME and actually fixing it would remember to close the corresponding issue. If there isn't an issue link, the issue (or rdar) probably won't get closed.

// FIXME: Support default arguments (rdar://142414553)
ctor->getNumParams() == 1 &&
ctor->getAccess() == clang::AS_public;
// FIXME: Support default arguments
Copy link
Contributor

Choose a reason for hiding this comment

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

Accidental change?

Comment on lines +1757 to +1758
if (!useAddress)
getterDecl->setImplicit();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we mark this getter as implicit unconditionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we mark an Address or MutableAddress accessor as implicit, then in AbstractStorageDecl::getOpaqueAccessor we return nullptr instead of returning the accessor, which causes the compiler to crash. So I think that these kind of accessors are never supposed to be implicit, though I'm not sure what's the reasoning behind this. We also use this trick in SwiftDeclSynthesizer::makeDereferencedPointeeProperty

Comment on lines +1797 to +1798
if (!useAddress)
setterDecl->setImplicit();
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

Copy link
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.

nice

@susmonteiro
Copy link
Contributor Author

@swift-ci please smoke test

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.

5 participants