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): protected property accessors missing #2738

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gh-pages/content/specification/6-compliance-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This section details the current state of each language binding with respect to our standard compliance suite.


| number | test | java (100.00%) | golang (73.50%) | Dotnet | Python |
| number | test | java (100.00%) | golang (75.21%) | Dotnet | Python |
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------------------------------------- | ------ | ------ |
| 1 | asyncOverrides_overrideCallsSuper | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ |
| 2 | [arrayReturnedByMethodCanBeRead]("Array created in the kernel can be queried for its elements") | 🟢 | 🟢 | ⭕ | ⭕ |
Expand Down Expand Up @@ -55,7 +55,7 @@ This section details the current state of each language binding with respect to
| 46 | useNestedStruct | 🟢 | 🟢 | ⭕ | ⭕ |
| 47 | testFluentApiWithDerivedClasses | 🟢 | 🟢 | ⭕ | ⭕ |
| 48 | interfacesCanBeUsedTransparently_WhenAddedToJsiiType | 🟢 | 🟢 | ⭕ | ⭕ |
| 49 | canOverrideProtectedGetter | 🟢 | [🔴](https://github.com/aws/jsii/issues/2673) | ⭕ | ⭕ |
| 49 | canOverrideProtectedGetter | 🟢 | 🟢 | ⭕ | ⭕ |
| 50 | getAndSetEnumValues | 🟢 | 🟢 | ⭕ | ⭕ |
| 51 | structs_nonOptionalequals | 🟢 | 🟢 | ⭕ | ⭕ |
| 52 | testInterfaceParameter | 🟢 | 🟢 | ⭕ | ⭕ |
Expand All @@ -66,7 +66,7 @@ This section details the current state of each language binding with respect to
| 57 | eraseUnsetDataValues | 🟢 | 🟢 | ⭕ | ⭕ |
| 58 | maps | 🟢 | 🟢 | ⭕ | ⭕ |
| 59 | structs_containsNullChecks | 🟢 | [🔴](https://github.com/aws/jsii/issues/2672) | ⭕ | ⭕ |
| 60 | canOverrideProtectedSetter | 🟢 | [🔴](https://github.com/aws/jsii/issues/2673) | ⭕ | ⭕ |
| 60 | canOverrideProtectedSetter | 🟢 | 🟢 | ⭕ | ⭕ |
| 61 | asyncOverrides_callAsyncMethod | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ |
| 62 | nodeStandardLibrary | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ |
| 63 | dates | 🟢 | 🟢 | ⭕ | ⭕ |
Expand Down
26 changes: 19 additions & 7 deletions packages/@jsii/go-runtime-test/project/compliance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (suite *ComplianceSuite) TestEqualsIsResistantToPropertyShadowingResultVari
}

type overridableProtectedMemberDerived struct {
calc.OverridableProtectedMember `overrides:"OverrideReadOnly,OverrideReadeWrite"`
calc.OverridableProtectedMember `overrides:"OverrideReadOnly,OverrideReadWrite"`
iliapolo marked this conversation as resolved.
Show resolved Hide resolved
}

func newOverridableProtectedMemberDerived() *overridableProtectedMemberDerived {
Expand All @@ -360,13 +360,11 @@ func (x *overridableProtectedMemberDerived) OverrideReadOnly() *string {
return jsii.String("Cthulhu ")
}

func (x *overridableProtectedMemberDerived) OverrideReadeWrite() *string {
func (x *overridableProtectedMemberDerived) OverrideReadWrite() *string {
return jsii.String("Fhtagn!")
}

func (suite *ComplianceSuite) TestCanOverrideProtectedGetter() {
suite.FailTest("unable to access protected members", "https://github.com/aws/jsii/issues/2673")

assert := suite.Assert()
overridden := newOverridableProtectedMemberDerived()
assert.Equal("Cthulhu Fhtagn!", *overridden.ValueFromProtected())
Expand Down Expand Up @@ -718,14 +716,28 @@ func (suite *ComplianceSuite) TestAbstractMembersAreCorrectlyHandled() {
}

func (suite *ComplianceSuite) TestCanOverrideProtectedSetter() {
suite.FailTest("unable to access protected members", "https://github.com/aws/jsii/issues/2673")
assert := suite.Assert()
challenge := "Bazzzzzzzzzzzaar..."
overridden := myOverridableProtectedMember{calc.NewOverridableProtectedMember()}
overridden := newTestCanOverrideProtectedSetterOverridableProtectedMember()
iliapolo marked this conversation as resolved.
Show resolved Hide resolved
overridden.SwitchModes()
assert.Equal(challenge, overridden.ValueFromProtected())
assert.Equal(challenge, *overridden.ValueFromProtected())
}

type TestCanOverrideProtectedSetterOverridableProtectedMember struct {
calc.OverridableProtectedMember `overrides:"OverrideReadWrite"`
}

func (x TestCanOverrideProtectedSetterOverridableProtectedMember) SetOverrideReadWrite(val *string) {
x.OverridableProtectedMember.SetOverrideReadWrite(jsii.String(fmt.Sprintf("zzzzzzzzz%s", *val)))
}

func newTestCanOverrideProtectedSetterOverridableProtectedMember() *TestCanOverrideProtectedSetterOverridableProtectedMember {
m := TestCanOverrideProtectedSetterOverridableProtectedMember{}
calc.NewOverridableProtectedMember_Override(&m)
return &m
}


func (suite *ComplianceSuite) TestObjRefsAreLabelledUsingWithTheMostCorrectType() {
assert := suite.Assert()

Expand Down
2 changes: 1 addition & 1 deletion packages/jsii-pacmak/lib/targets/go/types/type-member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class GoProperty implements GoTypeMember {

public emitSetterDecl(context: EmitContext) {
const { code } = context;
if (!this.property.protected && !this.immutable) {
if (!this.immutable) {
code.line(`Set${this.name}(val ${this.returnType})`);
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.