Skip to content

Commit 5e069aa

Browse files
author
Elad Ben-Israel
authored
fix(jsii): merge all "implements" declarations (#494)
When processing the merged set if "implements" declarations, do not override the "interfaces" section when there are multiple declaration sites (as in when a base class is erased). Fixes #493
1 parent 563d07b commit 5e069aa

File tree

16 files changed

+124
-12
lines changed

16 files changed

+124
-12
lines changed

packages/jsii-calc/lib/erasures.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ export interface IJSII417Derived extends IJSII417PrivateBase {
4444
//
4545
// tslint:disable-next-line:no-empty-interface
4646
export interface IJsii487External { }
47+
export interface IJsii487External2 { }
4748
class Jsii487Internal implements IJsii487External { }
48-
export class Jsii487Derived extends Jsii487Internal { }
49+
export class Jsii487Derived extends Jsii487Internal implements IJsii487External2 { }

packages/jsii-calc/test/assembly.jsii

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3045,6 +3045,16 @@
30453045
},
30463046
"name": "IJsii487External"
30473047
},
3048+
"jsii-calc.IJsii487External2": {
3049+
"assembly": "jsii-calc",
3050+
"fqn": "jsii-calc.IJsii487External2",
3051+
"kind": "interface",
3052+
"locationInModule": {
3053+
"filename": "lib/erasures.ts",
3054+
"line": 47
3055+
},
3056+
"name": "IJsii487External2"
3057+
},
30483058
"jsii-calc.IMutableObjectLiteral": {
30493059
"assembly": "jsii-calc",
30503060
"fqn": "jsii-calc.IMutableObjectLiteral",
@@ -4053,12 +4063,13 @@
40534063
"fqn": "jsii-calc.Jsii487Derived",
40544064
"initializer": {},
40554065
"interfaces": [
4066+
"jsii-calc.IJsii487External2",
40564067
"jsii-calc.IJsii487External"
40574068
],
40584069
"kind": "class",
40594070
"locationInModule": {
40604071
"filename": "lib/erasures.ts",
4061-
"line": 48
4072+
"line": 49
40624073
},
40634074
"name": "Jsii487Derived"
40644075
},
@@ -6768,5 +6779,5 @@
67686779
}
67696780
},
67706781
"version": "0.10.4",
6771-
"fingerprint": "JCVRuScD6uk2V+RQ+YfHSg6DG1z9qNmSY+Aug5NeTLY="
6782+
"fingerprint": "BTA5ERZWebBpBrjU3gv4/cr//8oiD3VyWbzqcJTNz7c="
67726783
}

packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3045,6 +3045,16 @@
30453045
},
30463046
"name": "IJsii487External"
30473047
},
3048+
"jsii-calc.IJsii487External2": {
3049+
"assembly": "jsii-calc",
3050+
"fqn": "jsii-calc.IJsii487External2",
3051+
"kind": "interface",
3052+
"locationInModule": {
3053+
"filename": "lib/erasures.ts",
3054+
"line": 47
3055+
},
3056+
"name": "IJsii487External2"
3057+
},
30483058
"jsii-calc.IMutableObjectLiteral": {
30493059
"assembly": "jsii-calc",
30503060
"fqn": "jsii-calc.IMutableObjectLiteral",
@@ -4053,12 +4063,13 @@
40534063
"fqn": "jsii-calc.Jsii487Derived",
40544064
"initializer": {},
40554065
"interfaces": [
4066+
"jsii-calc.IJsii487External2",
40564067
"jsii-calc.IJsii487External"
40574068
],
40584069
"kind": "class",
40594070
"locationInModule": {
40604071
"filename": "lib/erasures.ts",
4061-
"line": 48
4072+
"line": 49
40624073
},
40634074
"name": "Jsii487Derived"
40644075
},
@@ -6768,5 +6779,5 @@
67686779
}
67696780
},
67706781
"version": "0.10.4",
6771-
"fingerprint": "JCVRuScD6uk2V+RQ+YfHSg6DG1z9qNmSY+Aug5NeTLY="
6782+
"fingerprint": "BTA5ERZWebBpBrjU3gv4/cr//8oiD3VyWbzqcJTNz7c="
67726783
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Amazon.JSII.Runtime.Deputy;
2+
3+
namespace Amazon.JSII.Tests.CalculatorNamespace
4+
{
5+
[JsiiInterface(nativeType: typeof(IIJsii487External2), fullyQualifiedName: "jsii-calc.IJsii487External2")]
6+
public interface IIJsii487External2
7+
{
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Amazon.JSII.Runtime.Deputy;
2+
3+
namespace Amazon.JSII.Tests.CalculatorNamespace
4+
{
5+
[JsiiTypeProxy(nativeType: typeof(IIJsii487External2), fullyQualifiedName: "jsii-calc.IJsii487External2")]
6+
internal sealed class IJsii487External2Proxy : DeputyBase, IIJsii487External2
7+
{
8+
private IJsii487External2Proxy(ByRefValue reference): base(reference)
9+
{
10+
}
11+
}
12+
}

packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Jsii487Derived.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Amazon.JSII.Tests.CalculatorNamespace
44
{
55
[JsiiClass(nativeType: typeof(Jsii487Derived), fullyQualifiedName: "jsii-calc.Jsii487Derived")]
6-
public class Jsii487Derived : DeputyBase, IIJsii487External
6+
public class Jsii487Derived : DeputyBase, IIJsii487External2, IIJsii487External
77
{
88
public Jsii487Derived(): base(new DeputyProps(new object[]{}))
99
{

packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ protected Class<?> resolveClass(final String fqn) throws ClassNotFoundException
6868
case "jsii-calc.IJSII417Derived": return software.amazon.jsii.tests.calculator.IJSII417Derived.class;
6969
case "jsii-calc.IJSII417PublicBaseOfBase": return software.amazon.jsii.tests.calculator.IJSII417PublicBaseOfBase.class;
7070
case "jsii-calc.IJsii487External": return software.amazon.jsii.tests.calculator.IJsii487External.class;
71+
case "jsii-calc.IJsii487External2": return software.amazon.jsii.tests.calculator.IJsii487External2.class;
7172
case "jsii-calc.IMutableObjectLiteral": return software.amazon.jsii.tests.calculator.IMutableObjectLiteral.class;
7273
case "jsii-calc.INonInternalInterface": return software.amazon.jsii.tests.calculator.INonInternalInterface.class;
7374
case "jsii-calc.IPrivatelyImplemented": return software.amazon.jsii.tests.calculator.IPrivatelyImplemented.class;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package software.amazon.jsii.tests.calculator;
2+
3+
@javax.annotation.Generated(value = "jsii-pacmak")
4+
public interface IJsii487External2 extends software.amazon.jsii.JsiiSerializable {
5+
6+
/**
7+
* A proxy class which represents a concrete javascript instance of this type.
8+
*/
9+
final static class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IJsii487External2 {
10+
protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) {
11+
super(mode);
12+
}
13+
}
14+
}

packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Jsii487Derived.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@javax.annotation.Generated(value = "jsii-pacmak")
44
@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.Jsii487Derived")
5-
public class Jsii487Derived extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IJsii487External {
5+
public class Jsii487Derived extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IJsii487External2,software.amazon.jsii.tests.calculator.IJsii487External {
66
protected Jsii487Derived(final software.amazon.jsii.JsiiObject.InitializationMode mode) {
77
super(mode);
88
}

packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,18 @@ class _IJsii487ExternalProxy():
12861286
__jsii_type__ = "jsii-calc.IJsii487External"
12871287
pass
12881288

1289+
@jsii.interface(jsii_type="jsii-calc.IJsii487External2")
1290+
class IJsii487External2(jsii.compat.Protocol):
1291+
@staticmethod
1292+
def __jsii_proxy_class__():
1293+
return _IJsii487External2Proxy
1294+
1295+
pass
1296+
1297+
class _IJsii487External2Proxy():
1298+
__jsii_type__ = "jsii-calc.IJsii487External2"
1299+
pass
1300+
12891301
@jsii.interface(jsii_type="jsii-calc.IMutableObjectLiteral")
12901302
class IMutableObjectLiteral(jsii.compat.Protocol):
12911303
@staticmethod
@@ -1967,7 +1979,7 @@ def while_(self, value: str):
19671979
return jsii.set(self, "while", value)
19681980

19691981

1970-
@jsii.implements(IJsii487External)
1982+
@jsii.implements(IJsii487External2, IJsii487External)
19711983
class Jsii487Derived(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Jsii487Derived"):
19721984
def __init__(self) -> None:
19731985
jsii.create(Jsii487Derived, self, [])
@@ -3290,6 +3302,6 @@ def parts(self, value: typing.List[scope.jsii_calc_lib.Value]):
32903302
return jsii.set(self, "parts", value)
32913303

32923304

3293-
__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", "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"]
3305+
__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"]
32943306

32953307
publication.publish()

0 commit comments

Comments
 (0)