Skip to content

SILGen: Only set the external decl of a key path component if the accessor is public #23744

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

Conversation

aschwaighofer
Copy link
Contributor

rdar://49064011

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@aschwaighofer aschwaighofer requested a review from jckarter April 2, 2019 20:44
// RUN: %target-swift-frontend -primary-file %s -emit-ir -import-objc-header %S/Inputs/keypaths_c_types.h

// This used to crash while trying to emit a reference to the property
// descriptor for the some_field property.
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 be emitting property descriptors for imported 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.

No, but we did try to reference it because we had a key path that included an external decl for the imported type and the IRGen would try to emit a reference to the property descriptor here:

https://github.com/apple/swift/blob/8437ee5df089081a4f76b565db188b30ba33e498/lib/IRGen/GenKeyPath.cpp#L899

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I'm suggesting that we could in theory also emit property descriptors for computed properties of imported types. We'll need to do this so that equality and hashing of keypaths that reference imported types works across translation units -- we need to unique the descriptor at runtime, just like we do for foreign type metadata.

This looks like a fine fix in the interim, though. Do you mind filing a bug for implementing the runtime uniqueing of imported property descriptors? CC @jckarter who might have a better idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

The property descriptor is for resilience, not uniquing. For imported properties, we'd probably need to use a string for the uniquing ID.

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