diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index 1c169e4c1c..c87f019130 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -1056,7 +1056,7 @@ export interface IInterfaceWithOptionalMethodArguments { * Abstract return type */ -export interface InterfaceImplementedByAbstractClass { +export interface IInterfaceImplementedByAbstractClass { readonly propFromInterface: string; } @@ -1064,7 +1064,7 @@ export abstract class AbstractClassBase { public abstract readonly abstractProperty: string; } -export abstract class AbstractClass extends AbstractClassBase implements InterfaceImplementedByAbstractClass { +export abstract class AbstractClass extends AbstractClassBase implements IInterfaceImplementedByAbstractClass { public nonAbstractMethod() { return 42; } @@ -1091,7 +1091,7 @@ export class AbstractClassReturner { return new ConcreteClass(); } - public giveMeInterface(): InterfaceImplementedByAbstractClass { + public giveMeInterface(): IInterfaceImplementedByAbstractClass { return new ConcreteClass(); } diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 0d210f9588..ceeb986462 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -230,7 +230,7 @@ }, "interfaces": [ { - "fqn": "jsii-calc.InterfaceImplementedByAbstractClass" + "fqn": "jsii-calc.IInterfaceImplementedByAbstractClass" } ], "kind": "class", @@ -263,7 +263,7 @@ "immutable": true, "name": "propFromInterface", "overrides": { - "fqn": "jsii-calc.InterfaceImplementedByAbstractClass" + "fqn": "jsii-calc.IInterfaceImplementedByAbstractClass" }, "type": { "primitive": "string" @@ -308,7 +308,7 @@ { "name": "giveMeInterface", "returns": { - "fqn": "jsii-calc.InterfaceImplementedByAbstractClass" + "fqn": "jsii-calc.IInterfaceImplementedByAbstractClass" } } ], @@ -2032,6 +2032,25 @@ "kind": "interface", "name": "IFriendlyRandomGenerator" }, + "jsii-calc.IInterfaceImplementedByAbstractClass": { + "assembly": "jsii-calc", + "docs": { + "comment": "awslabs/jsii#220\nAbstract return type" + }, + "fqn": "jsii-calc.IInterfaceImplementedByAbstractClass", + "kind": "interface", + "name": "IInterfaceImplementedByAbstractClass", + "properties": [ + { + "abstract": true, + "immutable": true, + "name": "propFromInterface", + "type": { + "primitive": "string" + } + } + ] + }, "jsii-calc.IInterfaceThatShouldNotBeADataType": { "assembly": "jsii-calc", "docs": { @@ -2409,26 +2428,6 @@ ], "name": "InbetweenClass" }, - "jsii-calc.InterfaceImplementedByAbstractClass": { - "assembly": "jsii-calc", - "datatype": true, - "docs": { - "comment": "awslabs/jsii#220\nAbstract return type" - }, - "fqn": "jsii-calc.InterfaceImplementedByAbstractClass", - "kind": "interface", - "name": "InterfaceImplementedByAbstractClass", - "properties": [ - { - "abstract": true, - "immutable": true, - "name": "propFromInterface", - "type": { - "primitive": "string" - } - } - ] - }, "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo": { "assembly": "jsii-calc", "fqn": "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo", @@ -4633,5 +4632,5 @@ } }, "version": "0.8.2", - "fingerprint": "QQVEfUkkaxXMbXiD6wDVqdim8HdLW5L8CElwn+WdzUA=" + "fingerprint": "CSV1TF9zK+8oZfXWIov5XOKrTmFIpov07DaTV3k1IfA=" } diff --git a/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/JsiiVersionTest.java b/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/JsiiVersionTest.java index 784ec491d4..7b50d1f8f7 100644 --- a/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/JsiiVersionTest.java +++ b/packages/jsii-java-runtime-test/project/src/test/java/software/amazon/jsii/JsiiVersionTest.java @@ -2,6 +2,8 @@ import org.junit.Test; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; import static software.amazon.jsii.JsiiVersion.JSII_RUNTIME_VERSION; public final class JsiiVersionTest { @@ -27,4 +29,10 @@ public void incompatibleVersions_2() { public void incompatibleVersions_3() { JsiiRuntime.assertVersionCompatible("0.7.0+abcd", "1.2.0+abcd"); } + + @Test + public void versionIsDefined() { + assertNotNull(JSII_RUNTIME_VERSION); + assertNotEquals("", JSII_RUNTIME_VERSION); + } } 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 9791cc269a..227efb4ab6 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 @@ -27,7 +27,7 @@ import software.amazon.jsii.tests.calculator.IPublicInterface; import software.amazon.jsii.tests.calculator.IRandomNumberGenerator; import software.amazon.jsii.tests.calculator.InbetweenClass; -import software.amazon.jsii.tests.calculator.InterfaceImplementedByAbstractClass; +import software.amazon.jsii.tests.calculator.IInterfaceImplementedByAbstractClass; import software.amazon.jsii.tests.calculator.JSObjectLiteralForInterface; import software.amazon.jsii.tests.calculator.JSObjectLiteralToNative; import software.amazon.jsii.tests.calculator.JSObjectLiteralToNativeClass; @@ -868,7 +868,7 @@ public void returnAbstract() { assertEquals("propFromInterfaceValue", obj2.getPropFromInterface()); assertEquals(42, obj2.nonAbstractMethod()); - InterfaceImplementedByAbstractClass iface = obj.giveMeInterface(); + IInterfaceImplementedByAbstractClass iface = obj.giveMeInterface(); assertEquals("propFromInterfaceValue", iface.getPropFromInterface()); assertEquals("hello-abstract-property", obj.getReturnAbstractFromProperty().getAbstractProperty()); @@ -877,6 +877,7 @@ public void returnAbstract() { @Test public void doNotOverridePrivates_method_public() { DoNotOverridePrivates obj = new DoNotOverridePrivates() { + @SuppressWarnings("unused") public String privateMethod() { return "privateMethod-Override"; } @@ -888,6 +889,7 @@ public String privateMethod() { @Test public void doNotOverridePrivates_method_private() { DoNotOverridePrivates obj = new DoNotOverridePrivates() { + @SuppressWarnings("unused") private String privateMethod() { return "privateMethod-Override"; } @@ -899,6 +901,7 @@ private String privateMethod() { @Test public void doNotOverridePrivates_property_by_name_private() { DoNotOverridePrivates obj = new DoNotOverridePrivates() { + @SuppressWarnings("unused") private String privateProperty() { return "privateProperty-Override"; } @@ -910,6 +913,7 @@ private String privateProperty() { @Test public void doNotOverridePrivates_property_by_name_public() { DoNotOverridePrivates obj = new DoNotOverridePrivates() { + @SuppressWarnings("unused") public String privateProperty() { return "privateProperty-Override"; } @@ -921,9 +925,11 @@ public String privateProperty() { @Test public void doNotOverridePrivates_property_getter_public() { DoNotOverridePrivates obj = new DoNotOverridePrivates() { + @SuppressWarnings("unused") public String getPrivateProperty() { return "privateProperty-Override"; } + @SuppressWarnings("unused") public void setPrivateProperty(String value) { throw new RuntimeException("Boom"); } @@ -939,9 +945,11 @@ public void setPrivateProperty(String value) { @Test public void doNotOverridePrivates_property_getter_private() { DoNotOverridePrivates obj = new DoNotOverridePrivates() { + @SuppressWarnings("unused") private String getPrivateProperty() { return "privateProperty-Override"; } + @SuppressWarnings("unused") public void setPrivateProperty(String value) { throw new RuntimeException("Boom"); } 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 0d210f9588..ceeb986462 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 @@ -230,7 +230,7 @@ }, "interfaces": [ { - "fqn": "jsii-calc.InterfaceImplementedByAbstractClass" + "fqn": "jsii-calc.IInterfaceImplementedByAbstractClass" } ], "kind": "class", @@ -263,7 +263,7 @@ "immutable": true, "name": "propFromInterface", "overrides": { - "fqn": "jsii-calc.InterfaceImplementedByAbstractClass" + "fqn": "jsii-calc.IInterfaceImplementedByAbstractClass" }, "type": { "primitive": "string" @@ -308,7 +308,7 @@ { "name": "giveMeInterface", "returns": { - "fqn": "jsii-calc.InterfaceImplementedByAbstractClass" + "fqn": "jsii-calc.IInterfaceImplementedByAbstractClass" } } ], @@ -2032,6 +2032,25 @@ "kind": "interface", "name": "IFriendlyRandomGenerator" }, + "jsii-calc.IInterfaceImplementedByAbstractClass": { + "assembly": "jsii-calc", + "docs": { + "comment": "awslabs/jsii#220\nAbstract return type" + }, + "fqn": "jsii-calc.IInterfaceImplementedByAbstractClass", + "kind": "interface", + "name": "IInterfaceImplementedByAbstractClass", + "properties": [ + { + "abstract": true, + "immutable": true, + "name": "propFromInterface", + "type": { + "primitive": "string" + } + } + ] + }, "jsii-calc.IInterfaceThatShouldNotBeADataType": { "assembly": "jsii-calc", "docs": { @@ -2409,26 +2428,6 @@ ], "name": "InbetweenClass" }, - "jsii-calc.InterfaceImplementedByAbstractClass": { - "assembly": "jsii-calc", - "datatype": true, - "docs": { - "comment": "awslabs/jsii#220\nAbstract return type" - }, - "fqn": "jsii-calc.InterfaceImplementedByAbstractClass", - "kind": "interface", - "name": "InterfaceImplementedByAbstractClass", - "properties": [ - { - "abstract": true, - "immutable": true, - "name": "propFromInterface", - "type": { - "primitive": "string" - } - } - ] - }, "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo": { "assembly": "jsii-calc", "fqn": "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo", @@ -4633,5 +4632,5 @@ } }, "version": "0.8.2", - "fingerprint": "QQVEfUkkaxXMbXiD6wDVqdim8HdLW5L8CElwn+WdzUA=" + "fingerprint": "CSV1TF9zK+8oZfXWIov5XOKrTmFIpov07DaTV3k1IfA=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AbstractClass.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AbstractClass.cs index 7c3b7741cd..e33b22af8e 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AbstractClass.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AbstractClass.cs @@ -3,7 +3,7 @@ namespace Amazon.JSII.Tests.CalculatorNamespace { [JsiiClass(typeof(AbstractClass), "jsii-calc.AbstractClass", "[]")] - public abstract class AbstractClass : AbstractClassBase, IInterfaceImplementedByAbstractClass + public abstract class AbstractClass : AbstractClassBase, IIInterfaceImplementedByAbstractClass { protected AbstractClass(): base(new DeputyProps(new object[]{})) { diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AbstractClassReturner.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AbstractClassReturner.cs index e53457211b..1297118eb2 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AbstractClassReturner.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AbstractClassReturner.cs @@ -29,10 +29,10 @@ public virtual AbstractClass GiveMeAbstract() return InvokeInstanceMethod(new object[]{}); } - [JsiiMethod("giveMeInterface", "{\"fqn\":\"jsii-calc.InterfaceImplementedByAbstractClass\"}", "[]")] - public virtual IInterfaceImplementedByAbstractClass GiveMeInterface() + [JsiiMethod("giveMeInterface", "{\"fqn\":\"jsii-calc.IInterfaceImplementedByAbstractClass\"}", "[]")] + public virtual IIInterfaceImplementedByAbstractClass GiveMeInterface() { - return InvokeInstanceMethod(new object[]{}); + return InvokeInstanceMethod(new object[]{}); } } } \ 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/IInterfaceImplementedByAbstractClass.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIInterfaceImplementedByAbstractClass.cs similarity index 65% rename from packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IInterfaceImplementedByAbstractClass.cs rename to packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIInterfaceImplementedByAbstractClass.cs index 469679d0b7..cae70b61c7 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IInterfaceImplementedByAbstractClass.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IIInterfaceImplementedByAbstractClass.cs @@ -6,8 +6,8 @@ namespace Amazon.JSII.Tests.CalculatorNamespace /// awslabs/jsii#220 /// Abstract return type /// - [JsiiInterface(typeof(IInterfaceImplementedByAbstractClass), "jsii-calc.InterfaceImplementedByAbstractClass")] - public interface IInterfaceImplementedByAbstractClass + [JsiiInterface(typeof(IIInterfaceImplementedByAbstractClass), "jsii-calc.IInterfaceImplementedByAbstractClass")] + public interface IIInterfaceImplementedByAbstractClass { [JsiiProperty("propFromInterface", "{\"primitive\":\"string\"}")] string PropFromInterface diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/InterfaceImplementedByAbstractClassProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IInterfaceImplementedByAbstractClassProxy.cs similarity index 54% rename from packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/InterfaceImplementedByAbstractClassProxy.cs rename to packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IInterfaceImplementedByAbstractClassProxy.cs index 117c49e27d..36659f33ac 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/InterfaceImplementedByAbstractClassProxy.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IInterfaceImplementedByAbstractClassProxy.cs @@ -6,10 +6,10 @@ namespace Amazon.JSII.Tests.CalculatorNamespace /// awslabs/jsii#220 /// Abstract return type /// - [JsiiTypeProxy(typeof(IInterfaceImplementedByAbstractClass), "jsii-calc.InterfaceImplementedByAbstractClass")] - internal sealed class InterfaceImplementedByAbstractClassProxy : DeputyBase, IInterfaceImplementedByAbstractClass + [JsiiTypeProxy(typeof(IIInterfaceImplementedByAbstractClass), "jsii-calc.IInterfaceImplementedByAbstractClass")] + internal sealed class IInterfaceImplementedByAbstractClassProxy : DeputyBase, IIInterfaceImplementedByAbstractClass { - private InterfaceImplementedByAbstractClassProxy(ByRefValue reference): base(reference) + private IInterfaceImplementedByAbstractClassProxy(ByRefValue reference): base(reference) { } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/InterfaceImplementedByAbstractClass.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/InterfaceImplementedByAbstractClass.cs deleted file mode 100644 index 4b9d8f6936..0000000000 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/InterfaceImplementedByAbstractClass.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Amazon.JSII.Runtime.Deputy; - -namespace Amazon.JSII.Tests.CalculatorNamespace -{ - /// - /// awslabs/jsii#220 - /// Abstract return type - /// - [JsiiByValue] - public class InterfaceImplementedByAbstractClass : IInterfaceImplementedByAbstractClass - { - [JsiiProperty("propFromInterface", "{\"primitive\":\"string\"}", true)] - public string PropFromInterface - { - get; - set; - } - } -} \ 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 0283df9e08..4b25965827 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 @@ -55,6 +55,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.IAnotherPublicInterface": return software.amazon.jsii.tests.calculator.IAnotherPublicInterface.class; case "jsii-calc.IFriendlier": return software.amazon.jsii.tests.calculator.IFriendlier.class; case "jsii-calc.IFriendlyRandomGenerator": return software.amazon.jsii.tests.calculator.IFriendlyRandomGenerator.class; + case "jsii-calc.IInterfaceImplementedByAbstractClass": return software.amazon.jsii.tests.calculator.IInterfaceImplementedByAbstractClass.class; case "jsii-calc.IInterfaceThatShouldNotBeADataType": return software.amazon.jsii.tests.calculator.IInterfaceThatShouldNotBeADataType.class; case "jsii-calc.IInterfaceWithInternal": return software.amazon.jsii.tests.calculator.IInterfaceWithInternal.class; case "jsii-calc.IInterfaceWithMethods": return software.amazon.jsii.tests.calculator.IInterfaceWithMethods.class; @@ -74,7 +75,6 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.ImplementsPrivateInterface": return software.amazon.jsii.tests.calculator.ImplementsPrivateInterface.class; case "jsii-calc.ImplictBaseOfBase": return software.amazon.jsii.tests.calculator.ImplictBaseOfBase.class; case "jsii-calc.InbetweenClass": return software.amazon.jsii.tests.calculator.InbetweenClass.class; - case "jsii-calc.InterfaceImplementedByAbstractClass": return software.amazon.jsii.tests.calculator.InterfaceImplementedByAbstractClass.class; case "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo": return software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses.Foo.class; case "jsii-calc.InterfaceInNamespaceIncludesClasses.Hello": return software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses.Hello.class; case "jsii-calc.InterfaceInNamespaceOnlyInterface.Hello": return software.amazon.jsii.tests.calculator.InterfaceInNamespaceOnlyInterface.Hello.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AbstractClass.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AbstractClass.java index 78061b7876..3fea0d1d60 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AbstractClass.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AbstractClass.java @@ -2,7 +2,7 @@ @javax.annotation.Generated(value = "jsii-pacmak") @software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.AbstractClass") -public abstract class AbstractClass extends software.amazon.jsii.tests.calculator.AbstractClassBase implements software.amazon.jsii.tests.calculator.InterfaceImplementedByAbstractClass { +public abstract class AbstractClass extends software.amazon.jsii.tests.calculator.AbstractClassBase implements software.amazon.jsii.tests.calculator.IInterfaceImplementedByAbstractClass { protected AbstractClass(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/AbstractClassReturner.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AbstractClassReturner.java index 8e7f0b8803..06f29e9e66 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AbstractClassReturner.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AbstractClassReturner.java @@ -15,8 +15,8 @@ public software.amazon.jsii.tests.calculator.AbstractClass giveMeAbstract() { return this.jsiiCall("giveMeAbstract", software.amazon.jsii.tests.calculator.AbstractClass.class); } - public software.amazon.jsii.tests.calculator.InterfaceImplementedByAbstractClass giveMeInterface() { - return this.jsiiCall("giveMeInterface", software.amazon.jsii.tests.calculator.InterfaceImplementedByAbstractClass.class); + public software.amazon.jsii.tests.calculator.IInterfaceImplementedByAbstractClass giveMeInterface() { + return this.jsiiCall("giveMeInterface", software.amazon.jsii.tests.calculator.IInterfaceImplementedByAbstractClass.class); } public software.amazon.jsii.tests.calculator.AbstractClassBase getReturnAbstractFromProperty() { diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IInterfaceImplementedByAbstractClass.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IInterfaceImplementedByAbstractClass.java new file mode 100644 index 0000000000..f243430c88 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IInterfaceImplementedByAbstractClass.java @@ -0,0 +1,24 @@ +package software.amazon.jsii.tests.calculator; + +/** + * awslabs/jsii#220 + * Abstract return type + */ +@javax.annotation.Generated(value = "jsii-pacmak") +public interface IInterfaceImplementedByAbstractClass extends software.amazon.jsii.JsiiSerializable { + java.lang.String getPropFromInterface(); + + /** + * 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.IInterfaceImplementedByAbstractClass { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) { + super(mode); + } + + @Override + public java.lang.String getPropFromInterface() { + return this.jsiiGet("propFromInterface", java.lang.String.class); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceImplementedByAbstractClass.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceImplementedByAbstractClass.java deleted file mode 100644 index 2d82ab4fda..0000000000 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceImplementedByAbstractClass.java +++ /dev/null @@ -1,72 +0,0 @@ -package software.amazon.jsii.tests.calculator; - -/** - * awslabs/jsii#220 - * Abstract return type - */ -@javax.annotation.Generated(value = "jsii-pacmak") -public interface InterfaceImplementedByAbstractClass extends software.amazon.jsii.JsiiSerializable { - java.lang.String getPropFromInterface(); - - /** - * @return a {@link Builder} of {@link InterfaceImplementedByAbstractClass} - */ - static Builder builder() { - return new Builder(); - } - - /** - * A builder for {@link InterfaceImplementedByAbstractClass} - */ - final class Builder { - private java.lang.String _propFromInterface; - - /** - * Sets the value of PropFromInterface - * @param value the value to be set - * @return {@code this} - */ - public Builder withPropFromInterface(final java.lang.String value) { - this._propFromInterface = java.util.Objects.requireNonNull(value, "propFromInterface is required"); - return this; - } - - /** - * Builds the configured instance. - * @return a new instance of {@link InterfaceImplementedByAbstractClass} - * @throws NullPointerException if any required attribute was not provided - */ - public InterfaceImplementedByAbstractClass build() { - return new InterfaceImplementedByAbstractClass() { - private final java.lang.String $propFromInterface = java.util.Objects.requireNonNull(_propFromInterface, "propFromInterface is required"); - - @Override - public java.lang.String getPropFromInterface() { - return this.$propFromInterface; - } - - public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { - com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; - com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); - obj.set("propFromInterface", om.valueToTree(this.getPropFromInterface())); - return obj; - } - - }; - } - } - - /** - * 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.InterfaceImplementedByAbstractClass { - protected Jsii$Proxy(final software.amazon.jsii.JsiiObject.InitializationMode mode) { - super(mode); - } - - @Override - public java.lang.String getPropFromInterface() { - return this.jsiiGet("propFromInterface", java.lang.String.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 716edd6cc2..81201f4ee5 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 @@ -44,7 +44,7 @@ def give_me_abstract(self) -> "AbstractClass": return jsii.invoke(self, "giveMeAbstract", []) @jsii.member(jsii_name="giveMeInterface") - def give_me_interface(self) -> "InterfaceImplementedByAbstractClass": + def give_me_interface(self) -> "IInterfaceImplementedByAbstractClass": return jsii.invoke(self, "giveMeInterface", []) @property @@ -672,6 +672,56 @@ def goodbye(self) -> str: return jsii.invoke(self, "goodbye", []) +@jsii.interface(jsii_type="jsii-calc.IInterfaceImplementedByAbstractClass") +class IInterfaceImplementedByAbstractClass(jsii.compat.Protocol): + @staticmethod + def __jsii_proxy_class__(): + return _IInterfaceImplementedByAbstractClassProxy + + @property + @jsii.member(jsii_name="propFromInterface") + def prop_from_interface(self) -> str: + ... + + +class _IInterfaceImplementedByAbstractClassProxy(): + __jsii_type__ = "jsii-calc.IInterfaceImplementedByAbstractClass" + @property + @jsii.member(jsii_name="propFromInterface") + def prop_from_interface(self) -> str: + return jsii.get(self, "propFromInterface") + + +@jsii.implements(IInterfaceImplementedByAbstractClass) +class AbstractClass(AbstractClassBase, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.AbstractClass"): + @staticmethod + def __jsii_proxy_class__(): + return _AbstractClassProxy + + def __init__(self) -> None: + jsii.create(AbstractClass, self, []) + + @jsii.member(jsii_name="abstractMethod") + @abc.abstractmethod + def abstract_method(self, name: str) -> str: + ... + + @jsii.member(jsii_name="nonAbstractMethod") + def non_abstract_method(self) -> jsii.Number: + return jsii.invoke(self, "nonAbstractMethod", []) + + @property + @jsii.member(jsii_name="propFromInterface") + def prop_from_interface(self) -> str: + return jsii.get(self, "propFromInterface") + + +class _AbstractClassProxy(AbstractClass, jsii.proxy_for(AbstractClassBase)): + @jsii.member(jsii_name="abstractMethod") + def abstract_method(self, name: str) -> str: + return jsii.invoke(self, "abstractMethod", [name]) + + @jsii.interface(jsii_type="jsii-calc.IInterfaceWithInternal") class IInterfaceWithInternal(jsii.compat.Protocol): @staticmethod @@ -1159,40 +1209,6 @@ def private(self, value: str): class ImplictBaseOfBase(scope.jsii_calc_base.BaseProps, jsii.compat.TypedDict): goo: datetime.datetime -@jsii.data_type(jsii_type="jsii-calc.InterfaceImplementedByAbstractClass") -class InterfaceImplementedByAbstractClass(jsii.compat.TypedDict): - propFromInterface: str - -@jsii.implements(InterfaceImplementedByAbstractClass) -class AbstractClass(AbstractClassBase, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.AbstractClass"): - @staticmethod - def __jsii_proxy_class__(): - return _AbstractClassProxy - - def __init__(self) -> None: - jsii.create(AbstractClass, self, []) - - @jsii.member(jsii_name="abstractMethod") - @abc.abstractmethod - def abstract_method(self, name: str) -> str: - ... - - @jsii.member(jsii_name="nonAbstractMethod") - def non_abstract_method(self) -> jsii.Number: - return jsii.invoke(self, "nonAbstractMethod", []) - - @property - @jsii.member(jsii_name="propFromInterface") - def prop_from_interface(self) -> str: - return jsii.get(self, "propFromInterface") - - -class _AbstractClassProxy(AbstractClass, jsii.proxy_for(AbstractClassBase)): - @jsii.member(jsii_name="abstractMethod") - def abstract_method(self, name: str) -> str: - return jsii.invoke(self, "abstractMethod", [name]) - - class InterfaceInNamespaceIncludesClasses: class Foo(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.InterfaceInNamespaceIncludesClasses.Foo"): def __init__(self) -> None: @@ -2407,6 +2423,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", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumersOfThisCrazyTypeSystem", "DefaultedConstructorArgument", "DerivedClassHasNoProperties", "DerivedStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExportedBaseClass", "ExtendsInternalInterface", "ExtendsPrivateInterface", "GiveMeStructs", "GreetingAugmenter", "IAnotherPublicInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "ImplementInternalInterface", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceImplementedByAbstractClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SingleInstanceTwoTypes", "Statics", "StringEnum", "StripInternal", "Sum", "SyncVirtualMethods", "Thrower", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "__jsii_assembly__", "composition"] +__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AsyncVirtualMethods", "AugmentableClass", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumersOfThisCrazyTypeSystem", "DefaultedConstructorArgument", "DerivedClassHasNoProperties", "DerivedStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExportedBaseClass", "ExtendsInternalInterface", "ExtendsPrivateInterface", "GiveMeStructs", "GreetingAugmenter", "IAnotherPublicInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "ImplementInternalInterface", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SingleInstanceTwoTypes", "Statics", "StringEnum", "StripInternal", "Sum", "SyncVirtualMethods", "Thrower", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "__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 1baf94f367..09cb54a544 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 @@ -153,7 +153,7 @@ AbstractClass :extends: :py:class:`~jsii-calc.AbstractClassBase`\ - :implements: :py:class:`~jsii-calc.InterfaceImplementedByAbstractClass`\ + :implements: :py:class:`~jsii-calc.IInterfaceImplementedByAbstractClass`\ :abstract: Yes .. py:method:: abstractMethod(name) -> string @@ -171,7 +171,7 @@ AbstractClass .. py:attribute:: propFromInterface - *Implements* :py:meth:`jsii-calc.InterfaceImplementedByAbstractClass.propFromInterface` + *Implements* :py:meth:`jsii-calc.IInterfaceImplementedByAbstractClass.propFromInterface` :type: string *(readonly)* @@ -250,9 +250,9 @@ AbstractClassReturner :rtype: :py:class:`~jsii-calc.AbstractClass`\ - .. py:method:: giveMeInterface() -> jsii-calc.InterfaceImplementedByAbstractClass + .. py:method:: giveMeInterface() -> jsii-calc.IInterfaceImplementedByAbstractClass - :rtype: :py:class:`~jsii-calc.InterfaceImplementedByAbstractClass`\ + :rtype: :py:class:`~jsii-calc.IInterfaceImplementedByAbstractClass`\ .. py:attribute:: returnAbstractFromProperty @@ -2255,6 +2255,46 @@ IFriendlyRandomGenerator (interface) :abstract: Yes +IInterfaceImplementedByAbstractClass (interface) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. py:class:: IInterfaceImplementedByAbstractClass + + **Language-specific names:** + + .. tabs:: + + .. code-tab:: c# + + using Amazon.JSII.Tests.CalculatorNamespace; + + .. code-tab:: java + + import software.amazon.jsii.tests.calculator.IInterfaceImplementedByAbstractClass; + + .. code-tab:: javascript + + // IInterfaceImplementedByAbstractClass is an interface + + .. code-tab:: typescript + + import { IInterfaceImplementedByAbstractClass } from 'jsii-calc'; + + + + awslabs/jsii#220 + + Abstract return type + + + + + + .. py:attribute:: propFromInterface + + :type: string *(readonly)* + + IInterfaceThatShouldNotBeADataType (interface) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -3007,46 +3047,6 @@ InbetweenClass -InterfaceImplementedByAbstractClass (interface) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. py:class:: InterfaceImplementedByAbstractClass - - **Language-specific names:** - - .. tabs:: - - .. code-tab:: c# - - using Amazon.JSII.Tests.CalculatorNamespace; - - .. code-tab:: java - - import software.amazon.jsii.tests.calculator.InterfaceImplementedByAbstractClass; - - .. code-tab:: javascript - - // InterfaceImplementedByAbstractClass is an interface - - .. code-tab:: typescript - - import { InterfaceImplementedByAbstractClass } from 'jsii-calc'; - - - - awslabs/jsii#220 - - Abstract return type - - - - - - .. py:attribute:: propFromInterface - - :type: string *(readonly)* - - InterfaceInNamespaceIncludesClasses ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/packages/jsii-reflect/README.md b/packages/jsii-reflect/README.md index bd4574881c..c4f8beff8f 100644 --- a/packages/jsii-reflect/README.md +++ b/packages/jsii-reflect/README.md @@ -148,7 +148,7 @@ assemblies │ ├── IRandomNumberGenerator interface │ ├── IReturnsNumber interface │ ├── ImplictBaseOfBase interface - │ ├── InterfaceImplementedByAbstractClass interface + │ ├── IInterfaceImplementedByAbstractClass interface │ ├── Hello interface │ ├── Hello interface │ ├── InterfaceWithProperties interface diff --git a/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt b/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt index f10aff9c6f..f48d7e4496 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.all.expected.txt @@ -7,7 +7,7 @@ assemblies │ └─┬ types │ ├─┬ class AbstractClass │ │ ├── base: AbstractClassBase - │ │ ├── interfaces: InterfaceImplementedByAbstractClass + │ │ ├── interfaces: IInterfaceImplementedByAbstractClass │ │ └─┬ members │ │ ├─┬ () method │ │ │ └── returns: void @@ -37,7 +37,7 @@ assemblies │ │ ├─┬ giveMeAbstract() method │ │ │ └── returns: class:jsii-calc.AbstractClass │ │ ├─┬ giveMeInterface() method - │ │ │ └── returns: interface:jsii-calc.InterfaceImplementedByAbstractClass + │ │ │ └── returns: interface:jsii-calc.IInterfaceImplementedByAbstractClass │ │ └─┬ returnAbstractFromProperty property │ │ ├── immutable │ │ └── type: class:jsii-calc.AbstractClassBase @@ -1269,6 +1269,12 @@ assemblies │ │ │ ├── IRandomNumberGenerator │ │ │ └── IFriendly │ │ └── members + │ ├─┬ interface IInterfaceImplementedByAbstractClass + │ │ └─┬ members + │ │ └─┬ propFromInterface property + │ │ ├── abstract + │ │ ├── immutable + │ │ └── type: primitive:string │ ├─┬ interface IInterfaceThatShouldNotBeADataType │ │ ├─┬ interfaces │ │ │ └── IInterfaceWithMethods @@ -1367,12 +1373,6 @@ assemblies │ │ ├── abstract │ │ ├── immutable │ │ └── type: primitive:date - │ ├─┬ interface InterfaceImplementedByAbstractClass - │ │ └─┬ members - │ │ └─┬ propFromInterface property - │ │ ├── abstract - │ │ ├── immutable - │ │ └── type: primitive:string │ ├─┬ interface Hello │ │ └─┬ members │ │ └─┬ foo property diff --git a/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt b/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt index 17ad0296e1..8148eab7b6 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.inheritance.expected.txt @@ -3,7 +3,7 @@ assemblies │ └─┬ types │ ├─┬ class AbstractClass │ │ ├── base: AbstractClassBase - │ │ └── interfaces: InterfaceImplementedByAbstractClass + │ │ └── interfaces: IInterfaceImplementedByAbstractClass │ ├── class AbstractClassBase │ ├── class AbstractClassReturner │ ├─┬ class Add @@ -108,6 +108,7 @@ assemblies │ │ └─┬ interfaces │ │ ├── IRandomNumberGenerator │ │ └── IFriendly + │ ├── interface IInterfaceImplementedByAbstractClass │ ├─┬ interface IInterfaceThatShouldNotBeADataType │ │ └─┬ interfaces │ │ └── IInterfaceWithMethods @@ -130,7 +131,6 @@ assemblies │ ├─┬ interface ImplictBaseOfBase │ │ └─┬ interfaces │ │ └── BaseProps - │ ├── interface InterfaceImplementedByAbstractClass │ ├── interface Hello │ ├── interface Hello │ ├── interface LoadBalancedFargateServiceProps diff --git a/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt b/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt index 8570b981d5..ab3973baec 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.members.expected.txt @@ -524,6 +524,9 @@ assemblies │ │ └── goodbye() method │ ├─┬ interface IFriendlyRandomGenerator │ │ └── members + │ ├─┬ interface IInterfaceImplementedByAbstractClass + │ │ └─┬ members + │ │ └── propFromInterface property │ ├─┬ interface IInterfaceThatShouldNotBeADataType │ │ └─┬ members │ │ └── otherValue property @@ -569,9 +572,6 @@ assemblies │ ├─┬ interface ImplictBaseOfBase │ │ └─┬ members │ │ └── goo property - │ ├─┬ interface InterfaceImplementedByAbstractClass - │ │ └─┬ members - │ │ └── propFromInterface property │ ├─┬ interface Hello │ │ └─┬ members │ │ └── foo property diff --git a/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt b/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt index 936be4d26e..ffa5b9bdf8 100644 --- a/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt +++ b/packages/jsii-reflect/test/jsii-tree.test.types.expected.txt @@ -78,6 +78,7 @@ assemblies │ ├── interface IAnotherPublicInterface │ ├── interface IFriendlier │ ├── interface IFriendlyRandomGenerator + │ ├── interface IInterfaceImplementedByAbstractClass │ ├── interface IInterfaceThatShouldNotBeADataType │ ├── interface IInterfaceWithInternal │ ├── interface IInterfaceWithMethods @@ -92,7 +93,6 @@ assemblies │ ├── interface IRandomNumberGenerator │ ├── interface IReturnsNumber │ ├── interface ImplictBaseOfBase - │ ├── interface InterfaceImplementedByAbstractClass │ ├── interface Hello │ ├── interface Hello │ ├── interface LoadBalancedFargateServiceProps diff --git a/packages/jsii-reflect/test/typesystem.test.ts b/packages/jsii-reflect/test/typesystem.test.ts index 0f6a289f81..ff66c24a32 100644 --- a/packages/jsii-reflect/test/typesystem.test.ts +++ b/packages/jsii-reflect/test/typesystem.test.ts @@ -111,7 +111,7 @@ describe('Type', () => { test('with a class and an interface', () => { // GIVEN - const iface = typesys.findFqn('jsii-calc.InterfaceImplementedByAbstractClass'); + const iface = typesys.findFqn('jsii-calc.IInterfaceImplementedByAbstractClass'); const clazz = typesys.findFqn('jsii-calc.AbstractClass'); // THEN @@ -131,7 +131,7 @@ describe('Type', () => { describe('.allImplementations', () => { test('with an interface', () => { // GIVEN - const base = typesys.findFqn('jsii-calc.InterfaceImplementedByAbstractClass'); + const base = typesys.findFqn('jsii-calc.IInterfaceImplementedByAbstractClass'); // THEN expect(base.allImplementations).toEqual([typesys.findFqn('jsii-calc.AbstractClass'), base]); diff --git a/packages/jsii/lib/assembler.ts b/packages/jsii/lib/assembler.ts index f5646e5469..f154def906 100644 --- a/packages/jsii/lib/assembler.ts +++ b/packages/jsii/lib/assembler.ts @@ -446,6 +446,17 @@ export class Assembler implements Emitter { } jsiiType.interfaces = await this._processBaseInterfaces(fqn, clause.types.map(t => this._typeChecker.getTypeFromTypeNode(t))); + if (jsiiType.interfaces) { + this._deferUntilTypesAvailable(jsiiType.fqn, jsiiType.interfaces, type.symbol.valueDeclaration, (...ifaces) => { + for (const iface of ifaces) { + if (spec.isInterfaceType(iface) && iface.datatype) { + this._diagnostic(type.symbol.valueDeclaration, + ts.DiagnosticCategory.Error, + `Attempted to implement struct ${iface.fqn} from class ${jsiiType.fqn}`); + } + } + }); + } } if (!type.isClass()) { @@ -723,6 +734,19 @@ export class Assembler implements Emitter { prop.immutable = true; } } + } else { + // This is *NOT* a data type, so it may not extend something that is one. + for (const base of bases) { + if (!spec.isInterfaceType(base)) { + // Invalid type we already warned about earlier, just ignoring it here... + continue; + } + if (base.datatype) { + this._diagnostic(type.symbol.valueDeclaration, + ts.DiagnosticCategory.Error, + `Attempted to extend struct ${base.fqn} from regular interface ${jsiiType.fqn}`); + } + } } }); diff --git a/packages/jsii/test/negatives/neg.extend-struct.ts b/packages/jsii/test/negatives/neg.extend-struct.ts new file mode 100644 index 0000000000..0dcb43b9a0 --- /dev/null +++ b/packages/jsii/test/negatives/neg.extend-struct.ts @@ -0,0 +1,10 @@ +///!MATCH_ERROR: Attempted to extend struct jsii.Struct from regular interface jsii.IIllegal + +// Attempt to extend a Struct (aka data type) from a regular interface will fail. +export interface Struct { + readonly field: string; +} + +export interface IIllegal extends Struct { + method(): void; +} diff --git a/packages/jsii/test/negatives/neg.implement-struct.ts b/packages/jsii/test/negatives/neg.implement-struct.ts new file mode 100644 index 0000000000..7276beca8c --- /dev/null +++ b/packages/jsii/test/negatives/neg.implement-struct.ts @@ -0,0 +1,14 @@ +///!MATCH_ERROR: Attempted to implement struct jsii.Struct from class jsii.Illegal + +// Attempt to implement a Struct (aka data type) will fail. +export interface Struct { + readonly field: string; +} + +export class Illegal implements Struct { + public readonly field: string = 'foo'; + + public method(): void { + return; + } +} diff --git a/packages/jsii/test/negatives/neg.struct-extends-interface.ts b/packages/jsii/test/negatives/neg.struct-extends-interface.ts new file mode 100644 index 0000000000..04e152eba9 --- /dev/null +++ b/packages/jsii/test/negatives/neg.struct-extends-interface.ts @@ -0,0 +1,10 @@ +///!MATCH_ERROR: Interface contains behavior: name should be "IStruct" + +// Attempt to extend an interface from a struct (aka data type) +export interface IInterface { + readonly field: string; +} + +export interface Struct extends IInterface { + readonly another: number; +}