Skip to content

[Compile Time Constant Extraction] Add extraction of paren expressions #62816

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
merged 1 commit into from
Jan 4, 2023

Conversation

jPaolantonio
Copy link
Contributor

Add compile-time extraction of ParenExpr.

Supports the following types of extraction:

    static var float2: Float { return (6) }
    static var float3: Float { return (1 + 2) }
    let string2: String = ("Hi")
    var string3: String { ("Hey") }

@jPaolantonio
Copy link
Contributor Author

@swift-ci test

@artemcm
Copy link
Contributor

artemcm commented Jan 3, 2023

Does this handle (("hi"))? i.e. does the compiler automatically convert that to a single paren statement or would we need to recurse?

@jPaolantonio
Copy link
Contributor Author

Does this handle (("hi"))? i.e. does the compiler automatically convert that to a single paren statement or would we need to recurse?

Let me check + add a test case.

@jPaolantonio jPaolantonio force-pushed the const-extract-paren-expr branch from ff199bc to e676db6 Compare January 3, 2023 21:59
@jPaolantonio
Copy link
Contributor Author

@artemcm - Updated with nested parens and recursive extraction is working as expected.

@jPaolantonio
Copy link
Contributor Author

@swift-ci test

@jPaolantonio jPaolantonio merged commit 0d52c41 into swiftlang:main Jan 4, 2023
@jPaolantonio jPaolantonio deleted the const-extract-paren-expr branch January 17, 2023 20:55
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