Skip to content

Commit

Permalink
fix(go): Only embed behavioral interfaces (#1966)
Browse files Browse the repository at this point in the history
Previously, datatype structs were being embedded in the struct
interface. This fix moves the logic for looking up inherited interfaces
into classes only.
  • Loading branch information
SoManyHs committed Aug 28, 2020
1 parent 78b7b7d commit e1f4e18
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 20 deletions.
10 changes: 10 additions & 0 deletions packages/jsii-pacmak/lib/targets/golang/types/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,18 @@ export class GoClass extends GoStruct {
}

protected emitInterface(code: CodeMaker): void {
code.line('// Class interface'); // FIXME for debugging
code.openBlock(`type ${this.interfaceName} interface`);

const extended = this.type.getInterfaces(true);

// embed extended interfaces
if (extended.length !== 0) {
for (const iface of extended) {
code.line(iface.fqn);
}
}

for (const property of this.properties) {
property.emitGetterDecl(code);
property.emitSetterDecl(code);
Expand Down
9 changes: 0 additions & 9 deletions packages/jsii-pacmak/lib/targets/golang/types/go-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ export abstract class GoStruct extends GoType implements GoEmitter {
code.line('// Struct interface'); // FIXME for debugging
code.openBlock(`type ${this.interfaceName} interface`);

const extended = this.type.getInterfaces(true);

// embed extended interfaces
if (extended.length !== 0) {
for (const iface of extended) {
code.line(iface.fqn);
}
}

for (const property of this.properties) {
property.emitGetterDecl(code);
}
Expand Down
Loading

0 comments on commit e1f4e18

Please sign in to comment.