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

go: invalid code generated when a method is named like a base class #2702

Closed
1 of 5 tasks
eladb opened this issue Mar 15, 2021 · 1 comment · Fixed by #2703
Closed
1 of 5 tasks

go: invalid code generated when a method is named like a base class #2702

eladb opened this issue Mar 15, 2021 · 1 comment · Fixed by #2703
Assignees
Labels
bug This issue is a bug. cdk-blocker effort/small Small work item – less than a day of effort p2

Comments

@eladb
Copy link
Contributor

eladb commented Mar 15, 2021

🐛 Bug Report

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)
  • Go

General Information

  • JSII Version: 1.42.0
  • Platform: any

What is the problem?

// member has the same name as a base class
// @see https://github.com/aws/jsii/issues/2702

import { Base } from '@scope/jsii-calc-base';

export class Class1 extends Base {
  public base() {
    return;
  }
}

export class Class2 extends Base {
  public readonly base = 'hello';
}

Errors:

#STDERR> module2702/module2702.go:34:9: jsiiProxy_Class1.Base is a field, not a method
#STDERR> module2702/module2702.go:34:9: cannot use &j (type *jsiiProxy_Class1) as type Class1 in return argument:
#STDERR> 	*jsiiProxy_Class1 does not implement Class1 (missing Base method)
#STDERR> module2702/module2702.go:37:6: type jsiiProxy_Class1 has both field and method named Base
#STDERR> module2702/module2702.go:70:6: type jsiiProxy_Class2 has both field and method named Base
#STDERR> module2702/module2702.go:94:9: jsiiProxy_Class2.Base is a field, not a method
#STDERR> module2702/module2702.go:94:9: cannot use &j (type *jsiiProxy_Class2) as type Class2 in return argument:
#STDERR> 	*jsiiProxy_Class2 does not implement Class2 (missing Base method)
@eladb eladb added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. cdk-blocker labels Mar 15, 2021
@eladb eladb self-assigned this Mar 15, 2021
@eladb eladb assigned RomainMuller and unassigned eladb Mar 15, 2021
eladb pushed a commit that referenced this issue 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
@MrArnoldPalmer MrArnoldPalmer added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Mar 16, 2021
eladb pushed a commit that referenced this issue Mar 17, 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
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

mergify bot pushed a commit to aws/aws-cdk that referenced this issue Mar 25, 2021
Add `go` configuration to the `monocdk` and `aws-cdk-lib` packages. 

Resolves aws/jsii#2611

The following jsii bugs were fixed to enable this:

- [x] aws/jsii#2648
- [x] aws/jsii#2649
- [x] aws/jsii#2647
- [x] aws/jsii#2617
- [x] aws/jsii#2632
- [x] aws/jsii#2651
- [x] aws/jsii#2508
- [x] aws/jsii#2692
- [x] aws/jsii#2700
- [x] aws/jsii#2702

---

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
corrjo pushed a commit to corrjo/aws-cdk that referenced this issue Mar 25, 2021
Add `go` configuration to the `monocdk` and `aws-cdk-lib` packages.

Resolves aws/jsii#2611

The following jsii bugs were fixed to enable this:

- [x] aws/jsii#2648
- [x] aws/jsii#2649
- [x] aws/jsii#2647
- [x] aws/jsii#2617
- [x] aws/jsii#2632
- [x] aws/jsii#2651
- [x] aws/jsii#2508
- [x] aws/jsii#2692
- [x] aws/jsii#2700
- [x] aws/jsii#2702

---

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Mar 31, 2021
Add `go` configuration to the `monocdk` and `aws-cdk-lib` packages. 

Resolves aws/jsii#2611

The following jsii bugs were fixed to enable this:

- [x] aws/jsii#2648
- [x] aws/jsii#2649
- [x] aws/jsii#2647
- [x] aws/jsii#2617
- [x] aws/jsii#2632
- [x] aws/jsii#2651
- [x] aws/jsii#2508
- [x] aws/jsii#2692
- [x] aws/jsii#2700
- [x] aws/jsii#2702

---

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
Add `go` configuration to the `monocdk` and `aws-cdk-lib` packages.

Resolves aws/jsii#2611

The following jsii bugs were fixed to enable this:

- [x] aws/jsii#2648
- [x] aws/jsii#2649
- [x] aws/jsii#2647
- [x] aws/jsii#2617
- [x] aws/jsii#2632
- [x] aws/jsii#2651
- [x] aws/jsii#2508
- [x] aws/jsii#2692
- [x] aws/jsii#2700
- [x] aws/jsii#2702

---

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
eladb pushed a commit to cdklabs/decdk that referenced this issue Jan 18, 2022
Add `go` configuration to the `monocdk` and `aws-cdk-lib` packages. 

Resolves aws/jsii#2611

The following jsii bugs were fixed to enable this:

- [x] aws/jsii#2648
- [x] aws/jsii#2649
- [x] aws/jsii#2647
- [x] aws/jsii#2617
- [x] aws/jsii#2632
- [x] aws/jsii#2651
- [x] aws/jsii#2508
- [x] aws/jsii#2692
- [x] aws/jsii#2700
- [x] aws/jsii#2702

---

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. cdk-blocker effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants