From c2de100ecdf30dacfbad94cb4ff071feb22b2fc2 Mon Sep 17 00:00:00 2001 From: Romain Marcadier-Muller Date: Wed, 13 Nov 2019 09:52:51 +0100 Subject: [PATCH] fix(python): correctly handle interface declarations on returned objects (#980) When the returned type had a known base type, the interfaces tagged on the object reference tag. This addresses this problem. --- packages/jsii-calc/lib/compliance.ts | 28 ++++++ packages/jsii-calc/test/assembly.jsii | 95 ++++++++++++++++++- .../ComplianceTests.cs | 7 ++ .../amazon/jsii/testing/ComplianceTest.java | 6 ++ .../.jsii | 95 ++++++++++++++++++- .../Tests/CalculatorNamespace/BaseJsii976.cs | 23 +++++ .../CalculatorNamespace/IReturnJsii976.cs | 21 ++++ .../IReturnJsii976Proxy.cs | 25 +++++ .../CalculatorNamespace/SomeTypeJsii976.cs | 41 ++++++++ .../amazon/jsii/tests/calculator/$Module.java | 3 + .../jsii/tests/calculator/BaseJsii976.java | 23 +++++ .../jsii/tests/calculator/IReturnJsii976.java | 37 ++++++++ .../tests/calculator/SomeTypeJsii976.java | 39 ++++++++ .../python/src/jsii_calc/__init__.py | 76 ++++++++++++++- .../src/jsii/_reference_map.py | 44 +++++---- .../tests/test_compliance.py | 30 +++++- .../test/__snapshots__/jsii-tree.test.js.snap | 35 +++++++ .../__snapshots__/type-system.test.js.snap | 2 + 18 files changed, 608 insertions(+), 22 deletions(-) create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/BaseJsii976.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IReturnJsii976.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IReturnJsii976Proxy.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/SomeTypeJsii976.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/BaseJsii976.java create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IReturnJsii976.java create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/SomeTypeJsii976.java diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index 8a21f271bd..d7c865f321 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -2208,3 +2208,31 @@ export class RootStructValidator { private constructor() { } } + +/** + * Returns a subclass of a known class which implements an interface. + */ +export interface IReturnJsii976 { + readonly foo: number; +} + +export class BaseJsii976 { } + +export class SomeTypeJsii976 { + + static returnReturn(): IReturnJsii976 { + class Derived extends BaseJsii976 implements IReturnJsii976 { + public readonly foo = 333 + } + + return new Derived(); + } + + static returnAnonymous(): any { + class Derived implements IReturnJsii976 { + public readonly foo = 1337; + } + + return new Derived(); + } +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 5550b1c509..e373ae6f10 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -1236,6 +1236,20 @@ ], "name": "AugmentableClass" }, + "jsii-calc.BaseJsii976": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.BaseJsii976", + "initializer": {}, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2219 + }, + "name": "BaseJsii976" + }, "jsii-calc.Bell": { "assembly": "jsii-calc", "docs": { @@ -5140,6 +5154,37 @@ ], "name": "IRandomNumberGenerator" }, + "jsii-calc.IReturnJsii976": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental", + "summary": "Returns a subclass of a known class which implements an interface." + }, + "fqn": "jsii-calc.IReturnJsii976", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2215 + }, + "name": "IReturnJsii976", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2216 + }, + "name": "foo", + "type": { + "primitive": "number" + } + } + ] + }, "jsii-calc.IReturnsNumber": { "assembly": "jsii-calc", "docs": { @@ -8654,6 +8699,54 @@ ], "name": "SingletonStringEnum" }, + "jsii-calc.SomeTypeJsii976": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.SomeTypeJsii976", + "initializer": {}, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2221 + }, + "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2231 + }, + "name": "returnAnonymous", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2223 + }, + "name": "returnReturn", + "returns": { + "type": { + "fqn": "jsii-calc.IReturnJsii976" + } + }, + "static": true + } + ], + "name": "SomeTypeJsii976" + }, "jsii-calc.StableClass": { "assembly": "jsii-calc", "docs": { @@ -10913,5 +11006,5 @@ } }, "version": "0.20.3", - "fingerprint": "1F+uskR3++T5mjRcWge9oG3H/jJvXm1C3IhR1AwsBTE=" + "fingerprint": "umMeNAH41pX11GUAjHkw6RTyAwGCeTqRNJ2vPv5aeM0=" } diff --git a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs index f303b84aa2..2c6b9dff3c 100644 --- a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs +++ b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs @@ -1033,6 +1033,13 @@ public void VariadicCallbacksAreHandledCorrectly() Assert.Equal(new double[]{2d, 3d, 4d}, invoker.AsArray(1, 2, 3)); } + [Fact(DisplayName = Prefix + nameof(ReturnSubclassThatImplementsInterface976))] + public void ReturnSubclassThatImplementsInterface976() + { + var obj = SomeTypeJsii976.ReturnReturn(); + Assert.Equal(obj.Foo, 333); + } + private sealed class OverrideVariadicMethod : VariadicMethod { public override double[] AsArray(double first, params double[] others) diff --git a/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java b/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java index a904d729d5..45d8ca4ff8 100644 --- a/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java +++ b/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/testing/ComplianceTest.java @@ -1391,6 +1391,12 @@ public void correctlyDeserializesStructUnions() { assertTrue(StructUnionConsumer.isStructB(b1)); } + @Test + public void returnSubclassThatImplementsInterface976() { + IReturnJsii976 obj = SomeTypeJsii976.returnReturn(); + assertEquals(obj.getFoo(), 333); + } + static class PartiallyInitializedThisConsumerImpl extends PartiallyInitializedThisConsumer { @Override public String consumePartiallyInitializedThis(final ConstructorPassesThisOut obj, 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 5550b1c509..e373ae6f10 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 @@ -1236,6 +1236,20 @@ ], "name": "AugmentableClass" }, + "jsii-calc.BaseJsii976": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.BaseJsii976", + "initializer": {}, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2219 + }, + "name": "BaseJsii976" + }, "jsii-calc.Bell": { "assembly": "jsii-calc", "docs": { @@ -5140,6 +5154,37 @@ ], "name": "IRandomNumberGenerator" }, + "jsii-calc.IReturnJsii976": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental", + "summary": "Returns a subclass of a known class which implements an interface." + }, + "fqn": "jsii-calc.IReturnJsii976", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2215 + }, + "name": "IReturnJsii976", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2216 + }, + "name": "foo", + "type": { + "primitive": "number" + } + } + ] + }, "jsii-calc.IReturnsNumber": { "assembly": "jsii-calc", "docs": { @@ -8654,6 +8699,54 @@ ], "name": "SingletonStringEnum" }, + "jsii-calc.SomeTypeJsii976": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.SomeTypeJsii976", + "initializer": {}, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2221 + }, + "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2231 + }, + "name": "returnAnonymous", + "returns": { + "type": { + "primitive": "any" + } + }, + "static": true + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2223 + }, + "name": "returnReturn", + "returns": { + "type": { + "fqn": "jsii-calc.IReturnJsii976" + } + }, + "static": true + } + ], + "name": "SomeTypeJsii976" + }, "jsii-calc.StableClass": { "assembly": "jsii-calc", "docs": { @@ -10913,5 +11006,5 @@ } }, "version": "0.20.3", - "fingerprint": "1F+uskR3++T5mjRcWge9oG3H/jJvXm1C3IhR1AwsBTE=" + "fingerprint": "umMeNAH41pX11GUAjHkw6RTyAwGCeTqRNJ2vPv5aeM0=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/BaseJsii976.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/BaseJsii976.cs new file mode 100644 index 0000000000..a538d1669a --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/BaseJsii976.cs @@ -0,0 +1,23 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// + /// stability: Experimental + /// + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.BaseJsii976), fullyQualifiedName: "jsii-calc.BaseJsii976")] + public class BaseJsii976 : DeputyBase + { + public BaseJsii976(): base(new DeputyProps(new object[]{})) + { + } + + protected BaseJsii976(ByRefValue reference): base(reference) + { + } + + protected BaseJsii976(DeputyProps props): base(props) + { + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IReturnJsii976.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IReturnJsii976.cs new file mode 100644 index 0000000000..1e7ca91e79 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IReturnJsii976.cs @@ -0,0 +1,21 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Returns a subclass of a known class which implements an interface. + /// + /// stability: Experimental + /// + [JsiiInterface(nativeType: typeof(IReturnJsii976), fullyQualifiedName: "jsii-calc.IReturnJsii976")] + public interface IReturnJsii976 + { + /// + /// stability: Experimental + /// + [JsiiProperty(name: "foo", typeJson: "{\"primitive\":\"number\"}")] + double Foo + { + get; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IReturnJsii976Proxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IReturnJsii976Proxy.cs new file mode 100644 index 0000000000..f45fec410e --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IReturnJsii976Proxy.cs @@ -0,0 +1,25 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Returns a subclass of a known class which implements an interface. + /// + /// stability: Experimental + /// + [JsiiTypeProxy(nativeType: typeof(IReturnJsii976), fullyQualifiedName: "jsii-calc.IReturnJsii976")] + internal sealed class IReturnJsii976Proxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.IReturnJsii976 + { + private IReturnJsii976Proxy(ByRefValue reference): base(reference) + { + } + + /// + /// stability: Experimental + /// + [JsiiProperty(name: "foo", typeJson: "{\"primitive\":\"number\"}")] + public double Foo + { + get => GetInstanceProperty(); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/SomeTypeJsii976.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/SomeTypeJsii976.cs new file mode 100644 index 0000000000..2e69cee36d --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/SomeTypeJsii976.cs @@ -0,0 +1,41 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// + /// stability: Experimental + /// + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.SomeTypeJsii976), fullyQualifiedName: "jsii-calc.SomeTypeJsii976")] + public class SomeTypeJsii976 : DeputyBase + { + public SomeTypeJsii976(): base(new DeputyProps(new object[]{})) + { + } + + protected SomeTypeJsii976(ByRefValue reference): base(reference) + { + } + + protected SomeTypeJsii976(DeputyProps props): base(props) + { + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "returnAnonymous", returnsJson: "{\"type\":{\"primitive\":\"any\"}}")] + public static object ReturnAnonymous() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.SomeTypeJsii976), new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "returnReturn", returnsJson: "{\"type\":{\"fqn\":\"jsii-calc.IReturnJsii976\"}}")] + public static Amazon.JSII.Tests.CalculatorNamespace.IReturnJsii976 ReturnReturn() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.SomeTypeJsii976), new System.Type[]{}, new object[]{}); + } + } +} 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 9c27fed73b..6479594f2d 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 @@ -28,6 +28,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.AnonymousImplementationProvider": return software.amazon.jsii.tests.calculator.AnonymousImplementationProvider.class; case "jsii-calc.AsyncVirtualMethods": return software.amazon.jsii.tests.calculator.AsyncVirtualMethods.class; case "jsii-calc.AugmentableClass": return software.amazon.jsii.tests.calculator.AugmentableClass.class; + case "jsii-calc.BaseJsii976": return software.amazon.jsii.tests.calculator.BaseJsii976.class; case "jsii-calc.Bell": return software.amazon.jsii.tests.calculator.Bell.class; case "jsii-calc.BinaryOperation": return software.amazon.jsii.tests.calculator.BinaryOperation.class; case "jsii-calc.Calculator": return software.amazon.jsii.tests.calculator.Calculator.class; @@ -100,6 +101,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.IPublicInterface": return software.amazon.jsii.tests.calculator.IPublicInterface.class; case "jsii-calc.IPublicInterface2": return software.amazon.jsii.tests.calculator.IPublicInterface2.class; case "jsii-calc.IRandomNumberGenerator": return software.amazon.jsii.tests.calculator.IRandomNumberGenerator.class; + case "jsii-calc.IReturnJsii976": return software.amazon.jsii.tests.calculator.IReturnJsii976.class; case "jsii-calc.IReturnsNumber": return software.amazon.jsii.tests.calculator.IReturnsNumber.class; case "jsii-calc.IStableInterface": return software.amazon.jsii.tests.calculator.IStableInterface.class; case "jsii-calc.ImplementInternalInterface": return software.amazon.jsii.tests.calculator.ImplementInternalInterface.class; @@ -154,6 +156,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.SingletonIntEnum": return software.amazon.jsii.tests.calculator.SingletonIntEnum.class; case "jsii-calc.SingletonString": return software.amazon.jsii.tests.calculator.SingletonString.class; case "jsii-calc.SingletonStringEnum": return software.amazon.jsii.tests.calculator.SingletonStringEnum.class; + case "jsii-calc.SomeTypeJsii976": return software.amazon.jsii.tests.calculator.SomeTypeJsii976.class; case "jsii-calc.StableClass": return software.amazon.jsii.tests.calculator.StableClass.class; case "jsii-calc.StableEnum": return software.amazon.jsii.tests.calculator.StableEnum.class; case "jsii-calc.StableStruct": return software.amazon.jsii.tests.calculator.StableStruct.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/BaseJsii976.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/BaseJsii976.java new file mode 100644 index 0000000000..7f5c012371 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/BaseJsii976.java @@ -0,0 +1,23 @@ +package software.amazon.jsii.tests.calculator; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.BaseJsii976") +public class BaseJsii976 extends software.amazon.jsii.JsiiObject { + + protected BaseJsii976(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected BaseJsii976(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + public BaseJsii976() { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IReturnJsii976.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IReturnJsii976.java new file mode 100644 index 0000000000..fee978ab04 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IReturnJsii976.java @@ -0,0 +1,37 @@ +package software.amazon.jsii.tests.calculator; + +/** + * Returns a subclass of a known class which implements an interface. + * + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.IReturnJsii976") +@software.amazon.jsii.Jsii.Proxy(IReturnJsii976.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +public interface IReturnJsii976 extends software.amazon.jsii.JsiiSerializable { + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + java.lang.Number getFoo(); + + /** + * 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.IReturnJsii976 { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + /** + * EXPERIMENTAL + */ + @Override + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public java.lang.Number getFoo() { + return this.jsiiGet("foo", java.lang.Number.class); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/SomeTypeJsii976.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/SomeTypeJsii976.java new file mode 100644 index 0000000000..2c13b4913a --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/SomeTypeJsii976.java @@ -0,0 +1,39 @@ +package software.amazon.jsii.tests.calculator; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.SomeTypeJsii976") +public class SomeTypeJsii976 extends software.amazon.jsii.JsiiObject { + + protected SomeTypeJsii976(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected SomeTypeJsii976(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + public SomeTypeJsii976() { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Object returnAnonymous() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.SomeTypeJsii976.class, "returnAnonymous", java.lang.Object.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static software.amazon.jsii.tests.calculator.IReturnJsii976 returnReturn() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.SomeTypeJsii976.class, "returnReturn", software.amazon.jsii.tests.calculator.IReturnJsii976.class); + } +} 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 6a52bf4e90..46ff4b2c6c 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 @@ -553,6 +553,15 @@ def method_two(self) -> None: return jsii.invoke(self, "methodTwo", []) +class BaseJsii976(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.BaseJsii976"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(BaseJsii976, self, []) + + @jsii.implements(scope.jsii_calc_lib.IFriendly) class BinaryOperation(scope.jsii_calc_lib.Operation, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.BinaryOperation"): """Represents an operation with two operands. @@ -3743,6 +3752,44 @@ def next(self) -> jsii.Number: return jsii.invoke(self, "next", []) +@jsii.interface(jsii_type="jsii-calc.IReturnJsii976") +class IReturnJsii976(jsii.compat.Protocol): + """Returns a subclass of a known class which implements an interface. + + stability + :stability: experimental + """ + @staticmethod + def __jsii_proxy_class__(): + return _IReturnJsii976Proxy + + @property + @jsii.member(jsii_name="foo") + def foo(self) -> jsii.Number: + """ + stability + :stability: experimental + """ + ... + + +class _IReturnJsii976Proxy(): + """Returns a subclass of a known class which implements an interface. + + stability + :stability: experimental + """ + __jsii_type__ = "jsii-calc.IReturnJsii976" + @property + @jsii.member(jsii_name="foo") + def foo(self) -> jsii.Number: + """ + stability + :stability: experimental + """ + return jsii.get(self, "foo") + + @jsii.interface(jsii_type="jsii-calc.IReturnsNumber") class IReturnsNumber(jsii.compat.Protocol): """ @@ -6060,6 +6107,33 @@ class SingletonStringEnum(enum.Enum): :stability: experimental """ +class SomeTypeJsii976(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.SomeTypeJsii976"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(SomeTypeJsii976, self, []) + + @jsii.member(jsii_name="returnAnonymous") + @classmethod + def return_anonymous(cls) -> typing.Any: + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "returnAnonymous", []) + + @jsii.member(jsii_name="returnReturn") + @classmethod + def return_return(cls) -> "IReturnJsii976": + """ + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "returnReturn", []) + + class StableClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StableClass"): def __init__(self, readonly_string: str, mutable_number: typing.Optional[jsii.Number]=None) -> None: """ @@ -7659,6 +7733,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", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass", "Bell", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IBell", "IBellRinger", "IConcreteBellRinger", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "IStableInterface", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NestedStruct", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalArgumentInvoker", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RootStruct", "RootStructValidator", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicInvoker", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] +__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass", "BaseJsii976", "Bell", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IBell", "IBellRinger", "IConcreteBellRinger", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnJsii976", "IReturnsNumber", "IStableInterface", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NestedStruct", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalArgumentInvoker", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RootStruct", "RootStructValidator", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "SomeTypeJsii976", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicInvoker", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] publication.publish() diff --git a/packages/jsii-python-runtime/src/jsii/_reference_map.py b/packages/jsii-python-runtime/src/jsii/_reference_map.py index f4de964a6f..defa478e2f 100644 --- a/packages/jsii-python-runtime/src/jsii/_reference_map.py +++ b/packages/jsii-python-runtime/src/jsii/_reference_map.py @@ -49,6 +49,7 @@ def resolve(self, kernel, ref): # First we need to check our reference map to see if we have any instance that # already matches this reference. try: + # TODO: Handle discovery of possible new interfaces on the ObjRef return self._refs[ref.ref] except KeyError: pass @@ -69,6 +70,13 @@ def resolve(self, kernel, ref): # then assign our reference to __jsii_ref__ inst = klass.__new__(klass) inst.__jsii_ref__ = ref + + if ref.interfaces is not None: + return InterfaceDynamicProxy([inst] + self.build_interface_proxies_for_ref(ref)) + else: + return inst + + # Legacy code path - Kernel invariant ought to guarantee that class_fqn can't be Struct (they're interfaces) elif class_fqn in _data_types: # Data types have been serialized by-reference (see aws/jsii#400). # We retrieve all of its properties right now and then construct a value @@ -86,8 +94,9 @@ def resolve(self, kernel, ref): return data_type(**python_props) elif class_fqn in _enums: - inst = _enums[class_fqn] + return _enums[class_fqn] elif class_fqn == "Object" and ref.interfaces is not None: + # If any one interface is a struct, all of them are guaranteed to be (Kernel invariant) if any(fqn in _data_types for fqn in ref.interfaces): # Ugly delayed import here because I can't solve the cyclic # package dependency right now :(. @@ -100,20 +109,23 @@ def resolve(self, kernel, ref): }) for struct in structs] return StructDynamicProxy(insts) else: - ifaces = [_interfaces[fqn] for fqn in ref.interfaces] - classes = [iface.__jsii_proxy_class__() for iface in ifaces] - insts = [klass.__new__(klass) for klass in classes] - for inst in insts: - inst.__jsii_ref__ = ref - return InterfaceDynamicProxy(insts) + return InterfaceDynamicProxy(self.build_interface_proxies_for_ref(ref)) else: raise ValueError(f"Unknown type: {class_fqn}") - return inst - def resolve_id(self, id): return self._refs[id] + def build_interface_proxies_for_ref(self, ref): + if ref.interfaces is None: + raise AssertionError("Attempted to create interface proxies for ObjectRef without interfaces!") + ifaces = [_interfaces[fqn] for fqn in ref.interfaces] + classes = [iface.__jsii_proxy_class__() for iface in ifaces] + insts = [klass.__new__(klass) for klass in classes] + for inst in insts: + inst.__jsii_ref__ = ref + return insts + class InterfaceDynamicProxy(object): def __init__(self, delegates): @@ -121,11 +133,10 @@ def __init__(self, delegates): def __getattr__(self, name): for delegate in self._delegates: - try: + if hasattr(delegate, name): return getattr(delegate, name) - except NameError: - pass - return None + type_info = "+".join([str(delegate.__class__) for delegate in self._delegates]) + raise AttributeError(f"'%s' object has no attribute '%s'" % (type_info, name)) class StructDynamicProxy(object): @@ -134,11 +145,10 @@ def __init__(self, delegates): def __getattr__(self, name): for delegate in self._delegates: - try: + if hasattr(delegate, name): return getattr(delegate, name) - except NameError: - pass - return None + type_info = "+".join([str(delegate.__class__) for delegate in self._delegates]) + raise AttributeError("'%s' object has no attribute '%s'" % (type_info, name)) def __eq__(self, rhs) -> bool: if len(self._delegates) == 1: diff --git a/packages/jsii-python-runtime/tests/test_compliance.py b/packages/jsii-python-runtime/tests/test_compliance.py index 6c63c97889..93fcd3b166 100644 --- a/packages/jsii-python-runtime/tests/test_compliance.py +++ b/packages/jsii-python-runtime/tests/test_compliance.py @@ -48,14 +48,16 @@ EraseUndefinedHashValues, EraseUndefinedHashValuesOptions, VariadicMethod, - RootStruct, RootStructValidator, StructPassing, TopLevelStruct, SecondLevelStruct, StructA, StructB, - StructUnionConsumer + StructUnionConsumer, + SomeTypeJsii976, + AnonymousImplementationProvider, + IAnonymousImplementationProvider ) from scope.jsii_calc_lib import IFriendly, EnumFromScopedModule, Number @@ -1013,6 +1015,30 @@ def test_can_pass_nested_struct_as_dict(): } ) +def test_can_leverage_indirect_interface_polymorphism(): + provider = AnonymousImplementationProvider() + assert provider.provide_as_class().value == 1337 + assert provider.provide_as_interface().value == 1337 + assert provider.provide_as_interface().verb() == "to implement" + +# https://github.com/aws/jsii/issues/976 +def test_return_subclass_that_implements_interface_976(): + obj = SomeTypeJsii976.return_return() + assert obj.foo == 333 + +def test_return_subclass_that_implements_interface_976_raises_attributeerror_when_using_non_existent_method(): + obj = SomeTypeJsii976.return_return() + try: + print(obj.not_a_real_method_I_swear) + failed = False + except AttributeError as err: + failed = True + assert err.args[0] == "'+' object has no attribute 'not_a_real_method_I_swear'" + assert failed + +def test_return_anonymous_implementation_of_interface(): + assert SomeTypeJsii976.return_anonymous() is not None + @jsii.implements(IBellRinger) class PythonBellRinger: def your_turn(self, bell): diff --git a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap index 5ddff0ad79..a3fe368aa3 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap @@ -173,6 +173,9 @@ exports[`jsii-tree --all 1`] = ` │ │ │ └── returns: void │ │ └─┬ methodTwo() method (experimental) │ │ └── returns: void + │ ├─┬ class BaseJsii976 (experimental) + │ │ └─┬ members + │ │ └── () initializer (experimental) │ ├─┬ class Bell (experimental) │ │ ├── interfaces: IBell │ │ └─┬ members @@ -1181,6 +1184,15 @@ exports[`jsii-tree --all 1`] = ` │ │ │ └─┬ value │ │ │ └── type: string │ │ └── returns: boolean + │ ├─┬ class SomeTypeJsii976 (experimental) + │ │ └─┬ members + │ │ ├── () initializer (experimental) + │ │ ├─┬ static returnAnonymous() method (experimental) + │ │ │ ├── static + │ │ │ └── returns: any + │ │ └─┬ static returnReturn() method (experimental) + │ │ ├── static + │ │ └── returns: jsii-calc.IReturnJsii976 │ ├─┬ class StableClass (stable) │ │ └─┬ members │ │ ├─┬ (readonlyString,mutableNumber) initializer (stable) @@ -1835,6 +1847,12 @@ exports[`jsii-tree --all 1`] = ` │ │ └─┬ next() method (experimental) │ │ ├── abstract │ │ └── returns: number + │ ├─┬ interface IReturnJsii976 (experimental) + │ │ └─┬ members + │ │ └─┬ foo property (experimental) + │ │ ├── abstract + │ │ ├── immutable + │ │ └── type: number │ ├─┬ interface IReturnsNumber (experimental) │ │ └─┬ members │ │ ├─┬ obtainNumber() method (experimental) @@ -2192,6 +2210,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ │ └── interfaces: IAnonymousImplementationProvider │ ├── class AsyncVirtualMethods │ ├── class AugmentableClass + │ ├── class BaseJsii976 │ ├─┬ class Bell │ │ └── interfaces: IBell │ ├─┬ class BinaryOperation @@ -2284,6 +2303,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├── class SingleInstanceTwoTypes │ ├── class SingletonInt │ ├── class SingletonString + │ ├── class SomeTypeJsii976 │ ├── class StableClass │ ├── class StaticContext │ ├── class Statics @@ -2371,6 +2391,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├── interface IPublicInterface │ ├── interface IPublicInterface2 │ ├── interface IRandomNumberGenerator + │ ├── interface IReturnJsii976 │ ├── interface IReturnsNumber │ ├── interface IStableInterface │ ├─┬ interface ImplictBaseOfBase @@ -2509,6 +2530,9 @@ exports[`jsii-tree --members 1`] = ` │ │ ├── () initializer │ │ ├── methodOne() method │ │ └── methodTwo() method + │ ├─┬ class BaseJsii976 + │ │ └─┬ members + │ │ └── () initializer │ ├─┬ class Bell │ │ └─┬ members │ │ ├── () initializer @@ -2961,6 +2985,11 @@ exports[`jsii-tree --members 1`] = ` │ ├─┬ class SingletonString │ │ └─┬ members │ │ └── isSingletonString(value) method + │ ├─┬ class SomeTypeJsii976 + │ │ └─┬ members + │ │ ├── () initializer + │ │ ├── static returnAnonymous() method + │ │ └── static returnReturn() method │ ├─┬ class StableClass │ │ └─┬ members │ │ ├── (readonlyString,mutableNumber) initializer @@ -3225,6 +3254,9 @@ exports[`jsii-tree --members 1`] = ` │ ├─┬ interface IRandomNumberGenerator │ │ └─┬ members │ │ └── next() method + │ ├─┬ interface IReturnJsii976 + │ │ └─┬ members + │ │ └── foo property │ ├─┬ interface IReturnsNumber │ │ └─┬ members │ │ ├── obtainNumber() method @@ -3410,6 +3442,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── class AnonymousImplementationProvider │ ├── class AsyncVirtualMethods │ ├── class AugmentableClass + │ ├── class BaseJsii976 │ ├── class Bell │ ├── class BinaryOperation │ ├── class Calculator @@ -3481,6 +3514,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── class SingleInstanceTwoTypes │ ├── class SingletonInt │ ├── class SingletonString + │ ├── class SomeTypeJsii976 │ ├── class StableClass │ ├── class StaticContext │ ├── class Statics @@ -3542,6 +3576,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── interface IPublicInterface │ ├── interface IPublicInterface2 │ ├── interface IRandomNumberGenerator + │ ├── interface IReturnJsii976 │ ├── interface IReturnsNumber │ ├── interface IStableInterface │ ├── interface ImplictBaseOfBase diff --git a/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap b/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap index b46dddb198..1305905b47 100644 --- a/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap @@ -22,6 +22,7 @@ Array [ "AugmentableClass", "Base", "Base", + "BaseJsii976", "Bell", "BinaryOperation", "Calculator", @@ -95,6 +96,7 @@ Array [ "SingleInstanceTwoTypes", "SingletonInt", "SingletonString", + "SomeTypeJsii976", "StableClass", "StaticContext", "Statics",