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

fix(go): optional values #2705

Merged
merged 15 commits into from
Mar 18, 2021
Merged

fix(go): optional values #2705

merged 15 commits into from
Mar 18, 2021

Conversation

MrArnoldPalmer
Copy link
Contributor

Adds support for passing nil to jsii nullable types in generated go code.

Changes go code generation to always use "pointer types" for all struct fields, method arguments, and method return values. Update runtime type conversion to correctly handle serializing and deserializing to these pointer types where necessary.

Removes unnecessary functionality for resolving scoped interface names for generated go types as each generated type now has only one public name. Adds support for resolving scopedReferenceName to easily generate "pointer types" for complex data structures from a type reference.

RFC
fix: #2442
fix: #2671


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@MrArnoldPalmer MrArnoldPalmer added the language/go Regarding GoLang bindings label Mar 15, 2021
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 15, 2021
@MrArnoldPalmer MrArnoldPalmer force-pushed the feat/go-optional-values branch from 354dcb7 to f144831 Compare March 17, 2021 01:28
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

LGTM; added "do-not-merge" to let others chime in (@RomainMuller, @iliapolo)

@eladb eladb added the pr/do-not-merge This PR should not be merged at this time. label Mar 17, 2021
Comment on lines 12 to 13
delegate := StructReturningDelegate{expected: &expected}
consumer := calc.NewConsumePureInterface(&delegate)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why move the & from the declaration to the call site?

Also - expected was intentionally made by-value in StructReturningDelegate (this field is unexpected, and it'd be the go-y thing to do here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There appears to be a bug related to registering managed objects when this is passed by value instead of by reference. The only relevant change here is to the logic within the CastPtrToRef.

This also feels related to #2686 where structs passed by value that are fields of structs, and/or items within a slice, aren't being initialized correctly. Began hunting this down but need some more time.

packages/@jsii/go-runtime-test/project/compliance_test.go Outdated Show resolved Hide resolved
packages/@jsii/go-runtime-test/project/main_test.go Outdated Show resolved Hide resolved
packages/jsii-pacmak/lib/targets/go/types/class.ts Outdated Show resolved Hide resolved
@RomainMuller RomainMuller removed the pr/do-not-merge This PR should not be merged at this time. label Mar 18, 2021
@mergify
Copy link
Contributor

mergify bot commented Mar 18, 2021

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Mar 18, 2021
@mergify mergify bot merged commit 7d0cfc5 into main Mar 18, 2021
@mergify mergify bot deleted the feat/go-optional-values branch March 18, 2021 09:14
@mergify
Copy link
Contributor

mergify bot commented Mar 18, 2021

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. language/go Regarding GoLang bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

go: optional values are treated as empty values Go Optional Function Argument Support
3 participants