Skip to content

jsii: interfaces incorrectly marked as datatypes #264

@rix0rrr

Description

@rix0rrr

In the following case, the

interface IBaseInterface {
  readonly value: string;
  doSomething(): void;
}

interface IDerivedInterface extends IBaseInterface {
  readonly otherValue: string;
}

The interface IDerivedInterface is incorrectly marked as {datatype: true}, because the interface consists only of properties. Correct behavior would have been to take the parent interfaces into account as well while making this assessment.

This leads the Java code generator to emit a Builder that contains duplicate fields (and setters) and ignoring the methods in the upstream classes (encountered while making an IRole interface):

@aws-cdk/aws-iam: [ERROR] /tmp/jsii-pacmak-codeUbHgJB/src/main/java/software/amazon/awscdk/services/iam/IRole.java:[26,69] variable _principal is already defined in class software.amazon.awscdk.services.iam.IRole.Builder
@aws-cdk/aws-iam: [ERROR] /tmp/jsii-pacmak-codeUbHgJB/src/main/java/software/amazon/awscdk/services/iam/IRole.java:[52,24] method withPrincipal(software.amazon.awscdk.services.iam.PolicyPrincipal) is already defined in class software.amazon.awscdk.services.iam.IRole.Builder
@aws-cdk/aws-iam: [ERROR] /tmp/jsii-pacmak-codeUbHgJB/src/main/java/software/amazon/awscdk/services/iam/IRole.java:[76,83] variable $principal is already defined in class <anonymous software.amazon.awscdk.services.iam.IRole$Builder$1>
@aws-cdk/aws-iam: [ERROR] /tmp/jsii-pacmak-codeUbHgJB/src/main/java/software/amazon/awscdk/services/iam/IRole.java:[90,76] method getPrincipal() is already defined in class <anonymous software.amazon.awscdk.services.iam.IRole$Builder$1>
@aws-cdk/aws-iam: [ERROR] /tmp/jsii-pacmak-codeUbHgJB/src/main/java/software/amazon/awscdk/services/iam/IRole.java:[73,32] <anonymous software.amazon.awscdk.services.iam.IRole$Builder$1> is not abstract and does not override abstract method attachManagedPolicy(java.lang.String) in software.amazon.awscdk.services.iam.IPrincipal

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions