Skip to content

Correctly handle multiple interface inheritance #255

@skinny85

Description

@skinny85

When faced with an interface inheritance hierarchy like this:

interface CommonActionProps {
  runOrder: number;
  // ...
}

interface CommonActionConstructProps extends CommonActionProps {
  // ...
}

interface CommonPipelineSourceActionProps extends CommonActionProps {
  // ...
}

interface PipelineSourceActionProps extends CommonPipelineSourceActionProps,
    CommonActionConstructProps {
  // ...
}

which is valid TypeScript, JSII barfs when generating PipelineSourceActionProps with:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /tmp/jsii-pacmak-code9apQBY/src/main/java/software/amazon/awscdk/services/s3/PipelineSourceActionProps.java:[37,34] variable _runOrder is already defined in class software.amazon.awscdk.services.s3.PipelineSourceActionProps.Builder
[ERROR] /tmp/jsii-pacmak-code9apQBY/src/main/java/software/amazon/awscdk/services/s3/PipelineSourceActionProps.java:[101,24] method withRunOrder(java.lang.Number) is already defined in class software.amazon.awscdk.services.s3.PipelineSourceActionProps.Builder
[ERROR] /tmp/jsii-pacmak-code9apQBY/src/main/java/software/amazon/awscdk/services/s3/PipelineSourceActionProps.java:[122,42] variable $runOrder is already defined in class <anonymous software.amazon.awscdk.services.s3.PipelineSourceActionProps$Builder$1>
[ERROR] /tmp/jsii-pacmak-code9apQBY/src/main/java/software/amazon/awscdk/services/s3/PipelineSourceActionProps.java:[185,41] method getRunOrder() is already defined in class <anonymous software.amazon.awscdk.services.s3.PipelineSourceActionProps$Builder$1>
[ERROR] /tmp/jsii-pacmak-code9apQBY/src/main/java/software/amazon/awscdk/services/s3/PipelineSourceActionProps.java:[190,29] method setRunOrder(java.lang.Number) is already defined in class <anonymous software.amazon.awscdk.services.s3.PipelineSourceActionProps$Builder$1>
[INFO] 5 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.309 s
[INFO] Finished at: 2018-09-25T23:21:40+00:00
[INFO] Final Memory: 17M/291M
[INFO] ------------------------------------------------------------------------

It obviously tries to include the fields from the CommonActionProps interface twice, because it appears twice in the inheritance hierarchy for PipelineSourceActionProps.

The generators should detect when this happens, and only include the interface in the hierarchy once.

Found in #776.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.still-relevant?Checking to see if the issue is still relevant

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions