Skip to content

Commit

Permalink
fix(jsii): excessive overrides declarations registered (#3375)
Browse files Browse the repository at this point in the history
Members inherited from parent base classes, which also implemented a
locally implemented interface member, would get tagged with the
`overrides` marker for the interface, which was incorrect, since the
declaring type did not implement the interface directly.

This is solved by passing the inherited members by-copy to the
validator, so side effects of it aren't visible to the final assembly.



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
RomainMuller committed Feb 9, 2022
1 parent ae4ea62 commit 64a5984
Show file tree
Hide file tree
Showing 14 changed files with 737 additions and 18 deletions.
1 change: 1 addition & 0 deletions packages/jsii-calc/lib/index.ts
Expand Up @@ -8,6 +8,7 @@ export * from './nested-class';
export * from './stability';
export * from './submodules';
export * from './container-types';
export * from './indirect-implementation';

export * as submodule from './submodule';
export * as onlystatic from './only-static';
Expand Down
22 changes: 22 additions & 0 deletions packages/jsii-calc/lib/indirect-implementation.ts
@@ -0,0 +1,22 @@
export interface IIndirectlyImplemented {
readonly property: string;
method(): number;
}

export abstract class BaseClass {
public readonly property = 'YES';

protected constructor() {}

public method(): number {
return 1337;
}
}

export class FullCombo extends BaseClass implements IIndirectlyImplemented {
private constructor() {
super();
}

// Obtains implementation of IIndirectlyImplemented from BaseClass
}
148 changes: 136 additions & 12 deletions packages/jsii-calc/test/assembly.jsii
Expand Up @@ -208,7 +208,7 @@
"jsii-calc.cdk16625": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 23
"line": 24
},
"symbolId": "lib/cdk16625/index:"
},
Expand All @@ -229,28 +229,28 @@
"jsii-calc.module2530": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 20
"line": 21
},
"symbolId": "lib/module2530/index:"
},
"jsii-calc.module2617": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 16
"line": 17
},
"symbolId": "lib/module2617/index:"
},
"jsii-calc.module2647": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 15
"line": 16
},
"symbolId": "lib/module2647/index:"
},
"jsii-calc.module2689": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 17
"line": 18
},
"symbolId": "lib/module2689/index:"
},
Expand Down Expand Up @@ -285,7 +285,7 @@
"jsii-calc.module2692": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 19
"line": 20
},
"symbolId": "lib/module2692/index:"
},
Expand All @@ -306,21 +306,21 @@
"jsii-calc.module2700": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 21
"line": 22
},
"symbolId": "lib/module2700/index:"
},
"jsii-calc.module2702": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 18
"line": 19
},
"symbolId": "lib/module2702/index:"
},
"jsii-calc.nodirect": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 14
"line": 15
},
"symbolId": "lib/no-direct-types/index:"
},
Expand All @@ -341,14 +341,14 @@
"jsii-calc.onlystatic": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 13
"line": 14
},
"symbolId": "lib/only-static/index:"
},
"jsii-calc.submodule": {
"locationInModule": {
"filename": "lib/index.ts",
"line": 12
"line": 13
},
"readme": {
"markdown": "Read you, read me\n=================\n\nThis is the readme of the `jsii-calc.submodule` module.\n"
Expand Down Expand Up @@ -1652,6 +1652,63 @@
"name": "AugmentableClass",
"symbolId": "lib/compliance:AugmentableClass"
},
"jsii-calc.BaseClass": {
"abstract": true,
"assembly": "jsii-calc",
"docs": {
"stability": "stable"
},
"fqn": "jsii-calc.BaseClass",
"initializer": {
"docs": {
"stability": "stable"
},
"locationInModule": {
"filename": "lib/indirect-implementation.ts",
"line": 9
}
},
"kind": "class",
"locationInModule": {
"filename": "lib/indirect-implementation.ts",
"line": 6
},
"methods": [
{
"docs": {
"stability": "stable"
},
"locationInModule": {
"filename": "lib/indirect-implementation.ts",
"line": 11
},
"name": "method",
"returns": {
"type": {
"primitive": "number"
}
}
}
],
"name": "BaseClass",
"properties": [
{
"docs": {
"stability": "stable"
},
"immutable": true,
"locationInModule": {
"filename": "lib/indirect-implementation.ts",
"line": 7
},
"name": "property",
"type": {
"primitive": "string"
}
}
],
"symbolId": "lib/indirect-implementation:BaseClass"
},
"jsii-calc.BaseJsii976": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -5652,6 +5709,24 @@
],
"symbolId": "lib/stability:ExternalStruct"
},
"jsii-calc.FullCombo": {
"assembly": "jsii-calc",
"base": "jsii-calc.BaseClass",
"docs": {
"stability": "stable"
},
"fqn": "jsii-calc.FullCombo",
"interfaces": [
"jsii-calc.IIndirectlyImplemented"
],
"kind": "class",
"locationInModule": {
"filename": "lib/indirect-implementation.ts",
"line": 16
},
"name": "FullCombo",
"symbolId": "lib/indirect-implementation:FullCombo"
},
"jsii-calc.GiveMeStructs": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -6335,6 +6410,55 @@
"name": "IFriendlyRandomGenerator",
"symbolId": "lib/calculator:IFriendlyRandomGenerator"
},
"jsii-calc.IIndirectlyImplemented": {
"assembly": "jsii-calc",
"docs": {
"stability": "stable"
},
"fqn": "jsii-calc.IIndirectlyImplemented",
"kind": "interface",
"locationInModule": {
"filename": "lib/indirect-implementation.ts",
"line": 1
},
"methods": [
{
"abstract": true,
"docs": {
"stability": "stable"
},
"locationInModule": {
"filename": "lib/indirect-implementation.ts",
"line": 3
},
"name": "method",
"returns": {
"type": {
"primitive": "number"
}
}
}
],
"name": "IIndirectlyImplemented",
"properties": [
{
"abstract": true,
"docs": {
"stability": "stable"
},
"immutable": true,
"locationInModule": {
"filename": "lib/indirect-implementation.ts",
"line": 2
},
"name": "property",
"type": {
"primitive": "string"
}
}
],
"symbolId": "lib/indirect-implementation:IIndirectlyImplemented"
},
"jsii-calc.IInterfaceImplementedByAbstractClass": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -16807,5 +16931,5 @@
}
},
"version": "3.20.120",
"fingerprint": "lt+IM5wKyCp+HghCCEt9CX5x65ePqyHvu/emNzsxqbg="
"fingerprint": "sqJBfFAp4Hg5OgntWB3IRyRS7mpPF7G3qoh4NYSDeSw="
}

0 comments on commit 64a5984

Please sign in to comment.