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): embedded bases may conflict with member names #2703

Merged
merged 7 commits into from
Mar 17, 2021

Conversation

eladb
Copy link
Contributor

@eladb eladb commented Mar 15, 2021

When we generate proxy structs in Go (for classes or interfaces), we embed the base types (base class or interfaces) in the struct. If the base type has a name that is the same as a member of the hosting type, there will be a conflict.

To solve this, we create a unique type alias for each base interface we want to embed.

Fixes #2702


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

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 15, 2021
When we generate proxy structs in Go (for classes or interfaces), we embed the base types (base class or interfaces) in the struct. If the base type has a name that is the same as a member of the hosting type, there will be a conflict.

To solve this, we create a unique type alias for each base interface we want to embed.

Fixes #2702
@eladb eladb force-pushed the fix-field-method-conflict branch from c14d3f3 to 4ffac8b Compare March 15, 2021 18:03
@eladb eladb marked this pull request as ready for review March 15, 2021 18:05
@eladb eladb changed the title fix(go): conflict when member has same name as foreign base class fix(go): embedded bases may conflict with member names Mar 15, 2021
Copy link
Contributor

@MrArnoldPalmer MrArnoldPalmer left a comment

Choose a reason for hiding this comment

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

Just fixing the broken references to the new type alias, Otherwise LGTM 👍🏻

packages/jsii-pacmak/lib/targets/go/types/go-type.ts Outdated Show resolved Hide resolved
@eladb
Copy link
Contributor Author

eladb commented Mar 15, 2021

@MrArnoldPalmer I am seeing some runtime errors, so this needs a bit more work.

@eladb eladb requested a review from RomainMuller March 17, 2021 13:23
@eladb eladb merged commit 3594ad7 into main Mar 17, 2021
@eladb eladb deleted the fix-field-method-conflict branch March 17, 2021 15:32
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

go: invalid code generated when a method is named like a base class
3 participants