Skip to content

Commit

Permalink
fix(go): invalid generated code for classes a keyword name (#2641)
Browse files Browse the repository at this point in the history
Since these structs are all private, simply add a `_jsiiProxy` postfix to the name.

Fixes #2637
  • Loading branch information
Elad Ben-Israel authored Mar 3, 2021
1 parent 72f25af commit 8668f13
Show file tree
Hide file tree
Showing 12 changed files with 1,682 additions and 1,169 deletions.
11 changes: 11 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2944,3 +2944,14 @@ export class Issue2638B {
return; // no docs
}
}

/**
* A class named "Default"
*
* @see https://github.com/aws/jsii/issues/2637
*/
export class Default {
public pleaseCompile() {
return;
}
}
1 change: 1 addition & 0 deletions packages/jsii-calc/lib/submodule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * as returnsparam from './returns-param';
export * from './my-class';
export * from './nested_submodule';
export * as back_references from './refers-to-parent';
export * from './issue2637';
8 changes: 8 additions & 0 deletions packages/jsii-calc/lib/submodule/issue2637.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* A struct named "Default"
*
* @see https://github.com/aws/jsii/issues/2637
*/
export interface Default {
readonly foo: number;
}
68 changes: 67 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -3373,6 +3373,38 @@
],
"name": "DataRenderer"
},
"jsii-calc.Default": {
"assembly": "jsii-calc",
"docs": {
"see": "https://github.com/aws/jsii/issues/2637",
"stability": "stable",
"summary": "A class named \"Default\"."
},
"fqn": "jsii-calc.Default",
"initializer": {
"docs": {
"stability": "stable"
}
},
"kind": "class",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2953
},
"methods": [
{
"docs": {
"stability": "stable"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2954
},
"name": "pleaseCompile"
}
],
"name": "Default"
},
"jsii-calc.DefaultedConstructorArgument": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -14187,6 +14219,40 @@
"name": "OnlyStaticMethods",
"namespace": "onlystatic"
},
"jsii-calc.submodule.Default": {
"assembly": "jsii-calc",
"datatype": true,
"docs": {
"see": "https://github.com/aws/jsii/issues/2637",
"stability": "stable",
"summary": "A struct named \"Default\"."
},
"fqn": "jsii-calc.submodule.Default",
"kind": "interface",
"locationInModule": {
"filename": "lib/submodule/issue2637.ts",
"line": 6
},
"name": "Default",
"namespace": "submodule",
"properties": [
{
"abstract": true,
"docs": {
"stability": "stable"
},
"immutable": true,
"locationInModule": {
"filename": "lib/submodule/issue2637.ts",
"line": 7
},
"name": "foo",
"type": {
"primitive": "number"
}
}
]
},
"jsii-calc.submodule.MyClass": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -14804,5 +14870,5 @@
}
},
"version": "3.20.120",
"fingerprint": "WnxyYDpN1opFu5dYMKwKeo5wN3IkNe9gnovO0ro7i2U="
"fingerprint": "rH6rK3iHNatb4ojll7sd8rvJ4k/89Kybg89FRd96Hno="
}
4 changes: 3 additions & 1 deletion packages/jsii-pacmak/lib/targets/go/types/go-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export abstract class GoType {

public constructor(public pkg: Package, public type: Type) {
this.name = toPascalCase(type.name);
this.proxyName = toCamelCase(type.name);
// add "_jsiiProxy" postfix to private struct name to avoid keyword
// conflicts such as "default". see https://github.com/aws/jsii/issues/2637
this.proxyName = `${toCamelCase(type.name)}_jsiiProxy`;
this.fqn = type.fqn;
}

Expand Down

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

Loading

0 comments on commit 8668f13

Please sign in to comment.