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