Skip to content
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

[BEAM-6577] Examine func return types when generating shims #7720

Merged
merged 2 commits into from
Feb 4, 2019

Conversation

htyleo
Copy link
Contributor

@htyleo htyleo commented Feb 4, 2019

starcgenx.Extractor should examine both function input and output when extracting types from a package. Otherwise, the generated code may miss certain package imports.

R: @lostluck


Follow this checklist to help us incorporate your contribution quickly and easily:

  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

It will help us expedite review of your Pull Request if you tag someone (e.g. @username) to look at it.

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- --- --- --- ---
Java Build Status Build Status Build Status Build Status
Build Status
Build Status
Build Status Build Status Build Status
Python Build Status --- Build Status
Build Status
Build Status --- --- ---

starcgenx.Extractor should examine both function input and output when extracting types from a package. Otherwise, the generated code may miss certain package imports.
in := sig.Params() // *types.Tuple
for i := 0; i < in.Len(); i++ {
s := in.At(i) // *types.Var
for _, tuple := range []*types.Tuple{sig.Params(), sig.Results()} {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of expanding this one indentation deeper.
Consider moving the inside of the loop to a new function "extractFromTuple"
and then just calling it on both the Params and the Results.
Similarly, extractParameters, should be renamed to extractFromSignature

This matches the structure of the types in the go/types package, which makes it easier to customize further if necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comments! Refactored accordingly.

Rename extractParameters to extractFromSignature, which calls extractFromTuple using both params and results.
@htyleo htyleo changed the title Examine func return types when generating shims [BEAM-6577] Examine func return types when generating shims Feb 4, 2019
Copy link
Contributor

@lostluck lostluck 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 good to me, thanks for the fix!

@aaltay Please merge! Thank you.

@aaltay aaltay merged commit 3b139a7 into apache:master Feb 4, 2019
@htyleo htyleo deleted the shim-return-types branch October 18, 2021 21:43
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