From afed905a7a58957f43324bdd561437785998c92c Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Mon, 6 May 2019 17:07:27 +0300 Subject: [PATCH] fix(jsii): deduplicate interfaces When processing interfaces from multiple declaration sites (e.g. when a base class is erased), we need to make sure that only include every interface once. Fixes #496 --- packages/jsii-calc/lib/erasures.ts | 8 +++ packages/jsii-calc/test/assembly.jsii | 26 ++++++++- .../.jsii | 26 ++++++++- .../Tests/CalculatorNamespace/IIJsii496.cs | 9 +++ .../CalculatorNamespace/IJsii496Proxy.cs | 12 ++++ .../CalculatorNamespace/Jsii496Derived.cs | 20 +++++++ .../amazon/jsii/tests/calculator/$Module.java | 2 + .../jsii/tests/calculator/IJsii496.java | 14 +++++ .../jsii/tests/calculator/Jsii496Derived.java | 13 +++++ .../python/src/jsii_calc/__init__.py | 20 ++++++- .../expected.jsii-calc/sphinx/jsii-calc.rst | 58 +++++++++++++++++++ packages/jsii/lib/assembler.ts | 10 ++-- 12 files changed, 211 insertions(+), 7 deletions(-) create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIJsii496.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IJsii496Proxy.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Jsii496Derived.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IJsii496.java create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Jsii496Derived.java diff --git a/packages/jsii-calc/lib/erasures.ts b/packages/jsii-calc/lib/erasures.ts index 30077b8abd..c71400c540 100644 --- a/packages/jsii-calc/lib/erasures.ts +++ b/packages/jsii-calc/lib/erasures.ts @@ -48,3 +48,11 @@ export interface IJsii487External { } export interface IJsii487External2 { } class Jsii487Internal implements IJsii487External { } export class Jsii487Derived extends Jsii487Internal implements IJsii487External2 { } + +// +// Deduplicate interfaces that come from different declaration sites +// https://github.com/awslabs/jsii/issues/496 +// +export interface IJsii496 { } +class Jsii496Base implements IJsii496 { } +export class Jsii496Derived extends Jsii496Base implements IJsii496 { } diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 6e353dcdc6..e34075ee5f 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -3055,6 +3055,16 @@ }, "name": "IJsii487External2" }, + "jsii-calc.IJsii496": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.IJsii496", + "kind": "interface", + "locationInModule": { + "filename": "lib/erasures.ts", + "line": 56 + }, + "name": "IJsii496" + }, "jsii-calc.IMutableObjectLiteral": { "assembly": "jsii-calc", "fqn": "jsii-calc.IMutableObjectLiteral", @@ -4073,6 +4083,20 @@ }, "name": "Jsii487Derived" }, + "jsii-calc.Jsii496Derived": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.Jsii496Derived", + "initializer": {}, + "interfaces": [ + "jsii-calc.IJsii496" + ], + "kind": "class", + "locationInModule": { + "filename": "lib/erasures.ts", + "line": 58 + }, + "name": "Jsii496Derived" + }, "jsii-calc.JsiiAgent": { "assembly": "jsii-calc", "docs": { @@ -6779,5 +6803,5 @@ } }, "version": "0.10.5", - "fingerprint": "yLgYMXLhffrmN5U4ftTmlWijmxvKaKHA4QXx9+adYe0=" + "fingerprint": "Zn881YRFrX198/TaBpApis646FTCp/XbGmU7cWaw/cs=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii index 6e353dcdc6..e34075ee5f 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii @@ -3055,6 +3055,16 @@ }, "name": "IJsii487External2" }, + "jsii-calc.IJsii496": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.IJsii496", + "kind": "interface", + "locationInModule": { + "filename": "lib/erasures.ts", + "line": 56 + }, + "name": "IJsii496" + }, "jsii-calc.IMutableObjectLiteral": { "assembly": "jsii-calc", "fqn": "jsii-calc.IMutableObjectLiteral", @@ -4073,6 +4083,20 @@ }, "name": "Jsii487Derived" }, + "jsii-calc.Jsii496Derived": { + "assembly": "jsii-calc", + "fqn": "jsii-calc.Jsii496Derived", + "initializer": {}, + "interfaces": [ + "jsii-calc.IJsii496" + ], + "kind": "class", + "locationInModule": { + "filename": "lib/erasures.ts", + "line": 58 + }, + "name": "Jsii496Derived" + }, "jsii-calc.JsiiAgent": { "assembly": "jsii-calc", "docs": { @@ -6779,5 +6803,5 @@ } }, "version": "0.10.5", - "fingerprint": "yLgYMXLhffrmN5U4ftTmlWijmxvKaKHA4QXx9+adYe0=" + "fingerprint": "Zn881YRFrX198/TaBpApis646FTCp/XbGmU7cWaw/cs=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIJsii496.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIJsii496.cs new file mode 100644 index 0000000000..9f561e23c0 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIJsii496.cs @@ -0,0 +1,9 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiInterface(nativeType: typeof(IIJsii496), fullyQualifiedName: "jsii-calc.IJsii496")] + public interface IIJsii496 + { + } +} \ No newline at end of file diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IJsii496Proxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IJsii496Proxy.cs new file mode 100644 index 0000000000..f8895720e2 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IJsii496Proxy.cs @@ -0,0 +1,12 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiTypeProxy(nativeType: typeof(IIJsii496), fullyQualifiedName: "jsii-calc.IJsii496")] + internal sealed class IJsii496Proxy : DeputyBase, IIJsii496 + { + private IJsii496Proxy(ByRefValue reference): base(reference) + { + } + } +} \ No newline at end of file diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Jsii496Derived.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Jsii496Derived.cs new file mode 100644 index 0000000000..ddfdf96097 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Jsii496Derived.cs @@ -0,0 +1,20 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiClass(nativeType: typeof(Jsii496Derived), fullyQualifiedName: "jsii-calc.Jsii496Derived")] + public class Jsii496Derived : DeputyBase, IIJsii496 + { + public Jsii496Derived(): base(new DeputyProps(new object[]{})) + { + } + + protected Jsii496Derived(ByRefValue reference): base(reference) + { + } + + protected Jsii496Derived(DeputyProps props): base(props) + { + } + } +} \ No newline at end of file diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java index d2733b814f..8e4a955643 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java @@ -69,6 +69,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.IJSII417PublicBaseOfBase": return software.amazon.jsii.tests.calculator.IJSII417PublicBaseOfBase.class; case "jsii-calc.IJsii487External": return software.amazon.jsii.tests.calculator.IJsii487External.class; case "jsii-calc.IJsii487External2": return software.amazon.jsii.tests.calculator.IJsii487External2.class; + case "jsii-calc.IJsii496": return software.amazon.jsii.tests.calculator.IJsii496.class; case "jsii-calc.IMutableObjectLiteral": return software.amazon.jsii.tests.calculator.IMutableObjectLiteral.class; case "jsii-calc.INonInternalInterface": return software.amazon.jsii.tests.calculator.INonInternalInterface.class; case "jsii-calc.IPrivatelyImplemented": return software.amazon.jsii.tests.calculator.IPrivatelyImplemented.class; @@ -92,6 +93,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.JSObjectLiteralToNativeClass": return software.amazon.jsii.tests.calculator.JSObjectLiteralToNativeClass.class; case "jsii-calc.JavaReservedWords": return software.amazon.jsii.tests.calculator.JavaReservedWords.class; case "jsii-calc.Jsii487Derived": return software.amazon.jsii.tests.calculator.Jsii487Derived.class; + case "jsii-calc.Jsii496Derived": return software.amazon.jsii.tests.calculator.Jsii496Derived.class; case "jsii-calc.JsiiAgent": return software.amazon.jsii.tests.calculator.JsiiAgent.class; case "jsii-calc.LoadBalancedFargateServiceProps": return software.amazon.jsii.tests.calculator.LoadBalancedFargateServiceProps.class; case "jsii-calc.Multiply": return software.amazon.jsii.tests.calculator.Multiply.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IJsii496.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IJsii496.java new file mode 100644 index 0000000000..ead6b46bbf --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IJsii496.java @@ -0,0 +1,14 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +public interface IJsii496 extends software.amazon.jsii.JsiiSerializable { + + /** + * A proxy class which represents a concrete javascript instance of this type. + */ + final static class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IJsii496 { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Jsii496Derived.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Jsii496Derived.java new file mode 100644 index 0000000000..ff2488b43a --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Jsii496Derived.java @@ -0,0 +1,13 @@ +package software.amazon.jsii.tests.calculator; + +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.Jsii496Derived") +public class Jsii496Derived extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IJsii496 { + protected Jsii496Derived(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + public Jsii496Derived() { + super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py index 424d142005..32a237ced2 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py @@ -1298,6 +1298,18 @@ class _IJsii487External2Proxy(): __jsii_type__ = "jsii-calc.IJsii487External2" pass +@jsii.interface(jsii_type="jsii-calc.IJsii496") +class IJsii496(jsii.compat.Protocol): + @staticmethod + def __jsii_proxy_class__(): + return _IJsii496Proxy + + pass + +class _IJsii496Proxy(): + __jsii_type__ = "jsii-calc.IJsii496" + pass + @jsii.interface(jsii_type="jsii-calc.IMutableObjectLiteral") class IMutableObjectLiteral(jsii.compat.Protocol): @staticmethod @@ -1985,6 +1997,12 @@ def __init__(self) -> None: jsii.create(Jsii487Derived, self, []) +@jsii.implements(IJsii496) +class Jsii496Derived(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Jsii496Derived"): + def __init__(self) -> None: + jsii.create(Jsii496Derived, self, []) + + class JsiiAgent(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.JsiiAgent"): """Host runtime version should be set via JSII_AGENT.""" def __init__(self) -> None: @@ -3302,6 +3320,6 @@ def parts(self, value: typing.List[scope.jsii_calc_lib.Value]): return jsii.set(self, "parts", value) -__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AsyncVirtualMethods", "AugmentableClass", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithDocs", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumersOfThisCrazyTypeSystem", "DefaultedConstructorArgument", "DerivedClassHasNoProperties", "DerivedStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnotherPublicInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "ImplementInternalInterface", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SingleInstanceTwoTypes", "StaticContext", "Statics", "StringEnum", "StripInternal", "Sum", "SyncVirtualMethods", "Thrower", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "__jsii_assembly__", "composition"] +__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AsyncVirtualMethods", "AugmentableClass", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithDocs", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumersOfThisCrazyTypeSystem", "DefaultedConstructorArgument", "DerivedClassHasNoProperties", "DerivedStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnotherPublicInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "ImplementInternalInterface", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SingleInstanceTwoTypes", "StaticContext", "Statics", "StringEnum", "StripInternal", "Sum", "SyncVirtualMethods", "Thrower", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "__jsii_assembly__", "composition"] publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst b/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst index fcddc44071..21c0c5d711 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst +++ b/packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst @@ -2877,6 +2877,35 @@ IJsii487External2 (interface) +IJsii496 (interface) +^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: IJsii496 + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.IJsii496; + + .. code-tab:: javascript + + // IJsii496 is an interface + + .. code-tab:: typescript + + import { IJsii496 } from 'jsii-calc'; + + + + + IMutableObjectLiteral (interface) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -3972,6 +4001,35 @@ Jsii487Derived :implements: :py:class:`~jsii-calc.IJsii487External2`\ :implements: :py:class:`~jsii-calc.IJsii487External`\ +Jsii496Derived +^^^^^^^^^^^^^^ + +.. py:class:: Jsii496Derived() + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.Jsii496Derived; + + .. code-tab:: javascript + + const { Jsii496Derived } = require('jsii-calc'); + + .. code-tab:: typescript + + import { Jsii496Derived } from 'jsii-calc'; + + + + :implements: :py:class:`~jsii-calc.IJsii496`\ + JsiiAgent ^^^^^^^^^ diff --git a/packages/jsii/lib/assembler.ts b/packages/jsii/lib/assembler.ts index 905eb5d5de..7ddbf1e5b8 100644 --- a/packages/jsii/lib/assembler.ts +++ b/packages/jsii/lib/assembler.ts @@ -505,10 +505,12 @@ export class Assembler implements Emitter { } // process all "implements" clauses - jsiiType.interfaces = jsiiType.interfaces || []; + const allInterfaces = new Set(); for (const clause of implementsClauses) { const { interfaces } = await this._processBaseInterfaces(fqn, clause.types.map(t => this._typeChecker.getTypeFromTypeNode(t))); - jsiiType.interfaces.push(...(interfaces || []).map(i => i.fqn)); + for (const ifc of (interfaces || [])) { + allInterfaces.add(ifc.fqn); + } if (interfaces) { this._deferUntilTypesAvailable(jsiiType.fqn, interfaces, type.symbol.valueDeclaration, (...ifaces) => { for (const iface of ifaces) { @@ -522,8 +524,8 @@ export class Assembler implements Emitter { } } - if (jsiiType.interfaces.length === 0) { - delete jsiiType.interfaces; + if (allInterfaces.size > 0) { + jsiiType.interfaces = Array.from(allInterfaces); } if (!type.isClass()) {