Skip to content

[Compile Time Constant Extraction] Add extraction of property wrappers #62555

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

Merged

Conversation

jPaolantonio
Copy link
Contributor

Add compile-time extraction for variables attributed with property wrappers.

@jPaolantonio
Copy link
Contributor Author

@swift-ci test

@jPaolantonio jPaolantonio force-pushed the const-extraction-property-wrapper branch from 8614aa3 to 8684a1f Compare December 13, 2022 19:04
Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

This looks great.

// CHECK-NEXT: "kind": "struct",
// CHECK-NEXT: "properties": [
// CHECK-NEXT: {
// CHECK-NEXT: "label": "_propertyWrapper1",
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't necessarily a comment on this, and the current output actually captures what we do to the AST to de-sugar property-wrapped properties.

But I wonder if its best to leave this as-is and let clients figure out how to connect a property with an attribute to its corresponding underlying _ and $ properties, or if we can bundle them up here somehow. Wdyt @jPaolantonio?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a really great question, and one I don't quite have the answer for yet.

I briefly considered omitting _ and $ prefaced properties until we determined if they should be represented differently, but decided against it.

I think leaving them as-is for now to match the AST seems reasonable, but open to other ideas.

@jPaolantonio jPaolantonio force-pushed the const-extraction-property-wrapper branch from 8684a1f to c30c78a Compare December 13, 2022 20:34
@jPaolantonio
Copy link
Contributor Author

@swift-ci test

@jPaolantonio jPaolantonio merged commit b6d0986 into swiftlang:main Dec 14, 2022
@jPaolantonio jPaolantonio deleted the const-extraction-property-wrapper branch December 14, 2022 14:28
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.

2 participants