diff --git a/gh-pages/content/specification/6-compliance-report.md b/gh-pages/content/specification/6-compliance-report.md index d152111b14..52fa5f3828 100644 --- a/gh-pages/content/specification/6-compliance-report.md +++ b/gh-pages/content/specification/6-compliance-report.md @@ -5,7 +5,7 @@ This section details the current state of each language binding with respect to our standard compliance suite. -| number | test | java (98.36%) | golang (79.51%) | Dotnet | Python | +| number | test | java (97.56%) | golang (78.86%) | Dotnet | Python | | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | -------------------------------------------- | ------ | ------ | | 1 | asyncOverrides_overrideCallsSuper | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ | | 2 | [arrayReturnedByMethodCanBeRead]("Array created in the kernel can be queried for its elements") | 🟢 | 🟢 | ⭕ | ⭕ | @@ -129,3 +129,4 @@ This section details the current state of each language binding with respect to | 120 | [downcasting]("Ensures unsafe-cast features work as expected") | ⭕ | 🟢 | ⭕ | ⭕ | | 121 | [strippedDeprecatedMemberCanBeReceived]("Ensures --strip-deprecated does not cause odd runtime errors") | 🟢 | 🟢 | ⭕ | ⭕ | | 122 | [exceptionMessage]("Verifies that custom exception names are correctly forwarded") | 🟢 | 🟢 | ⭕ | ⭕ | +| 123 | [voidReturningAsync]("Verifies that returning Promise is correctly handled") | ⭕ | ⭕ | ⭕ | ⭕ | diff --git a/packages/@jsii/python-runtime/src/jsii/_kernel/types.py b/packages/@jsii/python-runtime/src/jsii/_kernel/types.py index 56fe6abc73..838a24f661 100644 --- a/packages/@jsii/python-runtime/src/jsii/_kernel/types.py +++ b/packages/@jsii/python-runtime/src/jsii/_kernel/types.py @@ -185,7 +185,7 @@ class EndRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class EndResponse: - result: Any + result: Optional[Any] = None @attr.s(auto_attribs=True, frozen=True, slots=True) diff --git a/packages/@jsii/python-runtime/tests/test_compliance.py b/packages/@jsii/python-runtime/tests/test_compliance.py index a68dce919c..9b09682462 100644 --- a/packages/@jsii/python-runtime/tests/test_compliance.py +++ b/packages/@jsii/python-runtime/tests/test_compliance.py @@ -76,6 +76,7 @@ StructParameterType, AnonymousImplementationProvider, UpcasingReflectable, + PromiseNothing, ) from jsii_calc.cdk16625 import Cdk16625 from jsii_calc.cdk22369 import AcceptsPath @@ -1354,3 +1355,11 @@ def test_stripped_deprecated_member_can_be_received(): def test_exception_message(): with pytest.raises(RuntimeError, match="Cannot find asset"): AcceptsPath(source_path="A Bad Path") + + +def test_void_returning_async(): + """Verifies it's okay to return a Promise.""" + + assert PromiseNothing().instance_promise_it() is None + ## TODO: This is currently broken as code-gen is incorrect for static async. + # assert PromiseNothing.promise_it() is None diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index e4669acb8b..725b1a3a7d 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -3131,3 +3131,13 @@ export interface ParamShadowsBuiltinsProps { readonly booleanProperty: boolean; readonly structProperty: StructA; } + +export class PromiseNothing { + public static async promiseIt(): Promise { + return Promise.resolve(); + } + + public async instancePromiseIt(): Promise { + return PromiseNothing.promiseIt(); + } +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 1525f7d7f2..135f668337 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -11823,6 +11823,50 @@ ], "symbolId": "lib/calculator:Power" }, + "jsii-calc.PromiseNothing": { + "assembly": "jsii-calc", + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.PromiseNothing", + "initializer": { + "docs": { + "stability": "stable" + } + }, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 3135 + }, + "methods": [ + { + "async": true, + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 3136 + }, + "name": "promiseIt", + "static": true + }, + { + "async": true, + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 3140 + }, + "name": "instancePromiseIt" + } + ], + "name": "PromiseNothing", + "symbolId": "lib/compliance:PromiseNothing" + }, "jsii-calc.PropertyNamedProperty": { "assembly": "jsii-calc", "docs": { @@ -18799,5 +18843,5 @@ } }, "version": "3.20.120", - "fingerprint": "kmlc5is+t/xffykk7b4m8jurrxFDkj9pjv2cW/V1J50=" + "fingerprint": "EH7xszNdCh9PCFUZ8Foi7g2CPhdrKeZm8CQaUCNv4GQ=" } \ No newline at end of file diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap index a9aaf179aa..f161783572 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap @@ -3199,6 +3199,7 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┣━ 📄 PartiallyInitializedThisConsumer.cs ┃ ┣━ 📄 Polymorphism.cs ┃ ┣━ 📄 Power.cs + ┃ ┣━ 📄 PromiseNothing.cs ┃ ┣━ 📄 PropertyNamedProperty.cs ┃ ┣━ 📄 PublicClass.cs ┃ ┣━ 📄 PythonReservedWords.cs @@ -17203,6 +17204,56 @@ namespace Amazon.JSII.Tests.CalculatorNamespace `; +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/PromiseNothing.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.PromiseNothing), fullyQualifiedName: "jsii-calc.PromiseNothing")] + public class PromiseNothing : DeputyBase + { + public PromiseNothing(): base(_MakeDeputyProps()) + { + } + + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + private static DeputyProps _MakeDeputyProps() + { + return new DeputyProps(System.Array.Empty()); + } + + /// Used by jsii to construct an instance of this class from a Javascript-owned object reference + /// The Javascript-owned object reference + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + protected PromiseNothing(ByRefValue reference): base(reference) + { + } + + /// Used by jsii to construct an instance of this class from DeputyProps + /// The deputy props + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + protected PromiseNothing(DeputyProps props): base(props) + { + } + + [JsiiMethod(name: "promiseIt", isAsync: true)] + public static void PromiseIt() + { + InvokeStaticVoidMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.PromiseNothing), new System.Type[]{}, new object[]{}); + } + + [JsiiMethod(name: "instancePromiseIt", isAsync: true)] + public virtual void InstancePromiseIt() + { + InvokeInstanceVoidMethod(new System.Type[]{}, new object[]{}); + } + } +} + +`; + exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/PropertyNamedProperty.cs 1`] = ` using Amazon.JSII.Runtime.Deputy; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.js.snap index 798561c3ae..023b06a4a9 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.js.snap @@ -2756,6 +2756,7 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┣━ 📄 jsiicalc_PartiallyInitializedThisConsumer.go ┣━ 📄 jsiicalc_Polymorphism.go ┣━ 📄 jsiicalc_Power.go + ┣━ 📄 jsiicalc_PromiseNothing.go ┣━ 📄 jsiicalc_PropertyNamedProperty.go ┣━ 📄 jsiicalc_PublicClass.go ┣━ 📄 jsiicalc_PythonReservedWords.go @@ -6278,6 +6279,16 @@ func init() { return &j }, ) + _jsii_.RegisterClass( + "jsii-calc.PromiseNothing", + reflect.TypeOf((*PromiseNothing)(nil)).Elem(), + []_jsii_.Member{ + _jsii_.MemberMethod{JsiiMethod: "instancePromiseIt", GoMethod: "InstancePromiseIt"}, + }, + func() interface{} { + return &jsiiProxy_PromiseNothing{} + }, + ) _jsii_.RegisterClass( "jsii-calc.PropertyNamedProperty", reflect.TypeOf((*PropertyNamedProperty)(nil)).Elem(), @@ -18103,6 +18114,69 @@ func (p *jsiiProxy_Power) TypeName() interface{} { } +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/jsiicalc_PromiseNothing.go 1`] = ` +// A simple calcuator built on JSII. +package jsiicalc + +import ( + _jsii_ "github.com/aws/jsii-runtime-go/runtime" + _init_ "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/jsii" +) + +type PromiseNothing interface { + InstancePromiseIt() +} + +// The jsii proxy struct for PromiseNothing +type jsiiProxy_PromiseNothing struct { + _ byte // padding +} + +func NewPromiseNothing() PromiseNothing { + _init_.Initialize() + + j := jsiiProxy_PromiseNothing{} + + _jsii_.Create( + "jsii-calc.PromiseNothing", + nil, // no parameters + &j, + ) + + return &j +} + +func NewPromiseNothing_Override(p PromiseNothing) { + _init_.Initialize() + + _jsii_.Create( + "jsii-calc.PromiseNothing", + nil, // no parameters + p, + ) +} + +func PromiseNothing_PromiseIt() { + _init_.Initialize() + + _jsii_.StaticInvokeVoid( + "jsii-calc.PromiseNothing", + "promiseIt", + nil, // no parameters + ) +} + +func (p *jsiiProxy_PromiseNothing) InstancePromiseIt() { + _jsii_.InvokeVoid( + p, + "instancePromiseIt", + nil, // no parameters + ) +} + + `; exports[`Generated code for "jsii-calc": /go/jsiicalc/jsiicalc_PropertyNamedProperty.go 1`] = ` diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.js.snap index 455d7b7748..73464f85aa 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.js.snap @@ -3930,6 +3930,7 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┣━ 📄 PartiallyInitializedThisConsumer.java ┃ ┣━ 📄 Polymorphism.java ┃ ┣━ 📄 Power.java + ┃ ┣━ 📄 PromiseNothing.java ┃ ┣━ 📄 PropertyNamedProperty.java ┃ ┣━ 📄 PublicClass.java ┃ ┣━ 📁 python_self @@ -19147,6 +19148,49 @@ public class Power extends software.amazon.jsii.tests.calculator.composition.Com `; +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/PromiseNothing.java 1`] = ` +package software.amazon.jsii.tests.calculator; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.PromiseNothing") +public class PromiseNothing extends software.amazon.jsii.JsiiObject { + + protected PromiseNothing(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected PromiseNothing(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public PromiseNothing() { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public static void promiseIt() { + software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.PromiseNothing.class, "promiseIt", software.amazon.jsii.NativeType.VOID); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public void instancePromiseIt() { + software.amazon.jsii.Kernel.asyncCall(this, "instancePromiseIt", software.amazon.jsii.NativeType.VOID); + } +} + +`; + exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/PropertyNamedProperty.java 1`] = ` package software.amazon.jsii.tests.calculator; @@ -29049,6 +29093,7 @@ jsii-calc.ParentStruct982=software.amazon.jsii.tests.calculator.ParentStruct982 jsii-calc.PartiallyInitializedThisConsumer=software.amazon.jsii.tests.calculator.PartiallyInitializedThisConsumer jsii-calc.Polymorphism=software.amazon.jsii.tests.calculator.Polymorphism jsii-calc.Power=software.amazon.jsii.tests.calculator.Power +jsii-calc.PromiseNothing=software.amazon.jsii.tests.calculator.PromiseNothing jsii-calc.PropertyNamedProperty=software.amazon.jsii.tests.calculator.PropertyNamedProperty jsii-calc.PublicClass=software.amazon.jsii.tests.calculator.PublicClass jsii-calc.PythonReservedWords=software.amazon.jsii.tests.calculator.PythonReservedWords diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap index 1bff67eae6..dc431dd154 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap @@ -8926,6 +8926,20 @@ class Power( return typing.cast(_scope_jsii_calc_lib_c61f082f.NumericValue, jsii.get(self, "pow")) +class PromiseNothing(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.PromiseNothing"): + def __init__(self) -> None: + jsii.create(self.__class__, self, []) + + @jsii.member(jsii_name="promiseIt") + @builtins.classmethod + def promise_it(cls) -> None: + return typing.cast(None, jsii.sinvoke(cls, "promiseIt", [])) + + @jsii.member(jsii_name="instancePromiseIt") + def instance_promise_it(self) -> None: + return typing.cast(None, jsii.ainvoke(self, "instancePromiseIt", [])) + + class PropertyNamedProperty( metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.PropertyNamedProperty", @@ -11433,6 +11447,7 @@ __all__ = [ "PartiallyInitializedThisConsumer", "Polymorphism", "Power", + "PromiseNothing", "PropertyNamedProperty", "PublicClass", "PythonReservedWords", @@ -16570,7 +16585,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="base") def base(self) -> _scope_jsii_calc_lib_c61f082f.NumericValue: -@@ -6073,10 +6582,13 @@ +@@ -6087,10 +6596,13 @@ value: _scope_jsii_calc_lib_c61f082f.EnumFromScopedModule, ) -> None: ''' @@ -16584,7 +16599,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="foo") def foo( -@@ -6087,10 +6599,13 @@ +@@ -6101,10 +6613,13 @@ @foo.setter def foo( self, @@ -16598,7 +16613,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class ReturnsPrivateImplementationOfInterface( metaclass=jsii.JSIIMeta, -@@ -6132,10 +6647,14 @@ +@@ -6146,10 +6661,14 @@ :param string_prop: May not be empty. :param nested_struct: ''' @@ -16613,7 +16628,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if nested_struct is not None: self._values["nested_struct"] = nested_struct -@@ -6202,17 +6721,25 @@ +@@ -6216,17 +6735,25 @@ ''' :param arg1: - :param arg2: - @@ -16639,7 +16654,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="methodWithOptionalArguments") def method_with_optional_arguments( self, -@@ -6224,10 +6751,15 @@ +@@ -6238,10 +6765,15 @@ :param arg1: - :param arg2: - @@ -16655,7 +16670,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.data_type( jsii_type="jsii-calc.SecondLevelStruct", -@@ -6246,10 +6778,14 @@ +@@ -6260,10 +6792,14 @@ ) -> None: ''' :param deeper_required_prop: It's long and required. @@ -16670,7 +16685,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if deeper_optional_prop is not None: self._values["deeper_optional_prop"] = deeper_optional_prop -@@ -6311,10 +6847,13 @@ +@@ -6325,10 +6861,13 @@ @jsii.member(jsii_name="isSingletonInt") def is_singleton_int(self, value: jsii.Number) -> builtins.bool: ''' @@ -16684,7 +16699,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.enum(jsii_type="jsii-calc.SingletonIntEnum") class SingletonIntEnum(enum.Enum): -@@ -6333,10 +6872,13 @@ +@@ -6347,10 +6886,13 @@ @jsii.member(jsii_name="isSingletonString") def is_singleton_string(self, value: builtins.str) -> builtins.bool: ''' @@ -16698,7 +16713,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.enum(jsii_type="jsii-calc.SingletonStringEnum") class SingletonStringEnum(enum.Enum): -@@ -6360,10 +6902,14 @@ +@@ -6374,10 +6916,14 @@ ) -> None: ''' :param property: @@ -16713,7 +16728,7 @@ exports[`Generated code for "jsii-calc": /python/src/js "yet_anoter_one": yet_anoter_one, } -@@ -6414,10 +6960,14 @@ +@@ -6428,10 +6974,14 @@ ) -> None: ''' :param readonly_string: - @@ -16728,7 +16743,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="method") def method(self) -> None: return typing.cast(None, jsii.invoke(self, "method", [])) -@@ -6432,10 +6982,13 @@ +@@ -6446,10 +6996,13 @@ def mutable_property(self) -> typing.Optional[jsii.Number]: return typing.cast(typing.Optional[jsii.Number], jsii.get(self, "mutableProperty")) @@ -16742,7 +16757,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.enum(jsii_type="jsii-calc.StableEnum") class StableEnum(enum.Enum): -@@ -6451,10 +7004,13 @@ +@@ -6465,10 +7018,13 @@ class StableStruct: def __init__(self, *, readonly_property: builtins.str) -> None: ''' @@ -16756,7 +16771,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } @builtins.property -@@ -6491,10 +7047,13 @@ +@@ -6505,10 +7061,13 @@ def static_variable(cls) -> builtins.bool: # pyright: ignore [reportGeneralTypeIssues] return typing.cast(builtins.bool, jsii.sget(cls, "staticVariable")) @@ -16770,7 +16785,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class StaticHelloParent( metaclass=jsii.JSIIMeta, -@@ -6524,19 +7083,25 @@ +@@ -6538,19 +7097,25 @@ class Statics(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Statics"): def __init__(self, value: builtins.str) -> None: ''' @@ -16796,7 +16811,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="justMethod") def just_method(self) -> builtins.str: return typing.cast(builtins.str, jsii.invoke(self, "justMethod", [])) -@@ -6573,19 +7138,25 @@ +@@ -6587,19 +7152,25 @@ ''' return typing.cast("Statics", jsii.sget(cls, "instance")) @@ -16822,7 +16837,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="value") def value(self) -> builtins.str: -@@ -6608,10 +7179,13 @@ +@@ -6622,10 +7193,13 @@ def you_see_me(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "youSeeMe")) @@ -16836,7 +16851,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.data_type( jsii_type="jsii-calc.StructA", -@@ -6634,10 +7208,15 @@ +@@ -6648,10 +7222,15 @@ :param required_string: :param optional_number: @@ -16852,7 +16867,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if optional_number is not None: self._values["optional_number"] = optional_number -@@ -6695,10 +7274,15 @@ +@@ -6709,10 +7288,15 @@ :param optional_boolean: :param optional_struct_a: ''' @@ -16868,7 +16883,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if optional_boolean is not None: self._values["optional_boolean"] = optional_boolean -@@ -6750,10 +7334,14 @@ +@@ -6764,10 +7348,14 @@ See: https://github.com/aws/aws-cdk/issues/4302 :param scope: @@ -16883,7 +16898,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if props is not None: self._values["props"] = props -@@ -6796,10 +7384,14 @@ +@@ -6810,10 +7398,14 @@ ) -> jsii.Number: ''' :param _positional: - @@ -16898,7 +16913,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="roundTrip") @builtins.classmethod def round_trip( -@@ -6814,10 +7406,13 @@ +@@ -6828,10 +7420,13 @@ :param _positional: - :param required: This is a required field. :param second_level: A union to really stress test our serialization. @@ -16912,7 +16927,7 @@ exports[`Generated code for "jsii-calc": /python/src/js ) return typing.cast("TopLevelStruct", jsii.sinvoke(cls, "roundTrip", [_positional, input])) -@@ -6834,10 +7429,13 @@ +@@ -6848,10 +7443,13 @@ struct: typing.Union[typing.Union[StructA, typing.Dict[builtins.str, typing.Any]], typing.Union[StructB, typing.Dict[builtins.str, typing.Any]]], ) -> builtins.bool: ''' @@ -16926,7 +16941,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="isStructB") @builtins.classmethod def is_struct_b( -@@ -6845,18 +7443,24 @@ +@@ -6859,18 +7457,24 @@ struct: typing.Union[typing.Union[StructA, typing.Dict[builtins.str, typing.Any]], typing.Union[StructB, typing.Dict[builtins.str, typing.Any]]], ) -> builtins.bool: ''' @@ -16951,7 +16966,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.data_type( jsii_type="jsii-calc.StructWithCollectionOfUnionts", -@@ -6870,10 +7474,13 @@ +@@ -6884,10 +7488,13 @@ union_property: typing.Sequence[typing.Mapping[builtins.str, typing.Union[typing.Union[StructA, typing.Dict[builtins.str, typing.Any]], typing.Union[StructB, typing.Dict[builtins.str, typing.Any]]]]], ) -> None: ''' @@ -16965,7 +16980,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } @builtins.property -@@ -6910,10 +7517,14 @@ +@@ -6924,10 +7531,14 @@ ) -> None: ''' :param foo: An enum value. @@ -16980,7 +16995,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if bar is not None: self._values["bar"] = bar -@@ -6969,10 +7580,16 @@ +@@ -6983,10 +7594,16 @@ :param default: :param assert_: :param result: @@ -16997,7 +17012,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if assert_ is not None: self._values["assert_"] = assert_ -@@ -7042,10 +7659,13 @@ +@@ -7056,10 +7673,13 @@ @parts.setter def parts( self, @@ -17011,7 +17026,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.data_type( jsii_type="jsii-calc.SupportsNiceJavaBuilderProps", -@@ -7061,10 +7681,14 @@ +@@ -7075,10 +7695,14 @@ ) -> None: ''' :param bar: Some number, like 42. @@ -17026,7 +17041,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if id is not None: self._values["id"] = id -@@ -7113,10 +7737,13 @@ +@@ -7127,10 +7751,13 @@ ''' :param id_: some identifier of your choice. :param bar: Some number, like 42. @@ -17040,7 +17055,7 @@ exports[`Generated code for "jsii-calc": /python/src/js jsii.create(self.__class__, self, [id_, props]) @builtins.property -@@ -7154,17 +7781,23 @@ +@@ -7168,17 +7795,23 @@ @jsii.member(jsii_name="modifyOtherProperty") def modify_other_property(self, value: builtins.str) -> None: ''' @@ -17064,7 +17079,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="readA") def read_a(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.invoke(self, "readA", [])) -@@ -7184,17 +7817,23 @@ +@@ -7198,17 +7831,23 @@ @jsii.member(jsii_name="virtualMethod") def virtual_method(self, n: jsii.Number) -> jsii.Number: ''' @@ -17088,7 +17103,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="readonlyProperty") def readonly_property(self) -> builtins.str: -@@ -7205,46 +7844,61 @@ +@@ -7219,46 +7858,61 @@ def a(self) -> jsii.Number: return typing.cast(jsii.Number, jsii.get(self, "a")) @@ -17150,7 +17165,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class TestStructWithEnum( metaclass=jsii.JSIIMeta, -@@ -7327,10 +7981,15 @@ +@@ -7341,10 +7995,15 @@ ''' :param required: This is a required field. :param second_level: A union to really stress test our serialization. @@ -17166,7 +17181,7 @@ exports[`Generated code for "jsii-calc": /python/src/js "second_level": second_level, } if optional is not None: -@@ -7421,10 +8080,13 @@ +@@ -7435,10 +8094,13 @@ def __init__(self, operand: _scope_jsii_calc_lib_c61f082f.NumericValue) -> None: ''' @@ -17180,7 +17195,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="operand") def operand(self) -> _scope_jsii_calc_lib_c61f082f.NumericValue: -@@ -7455,10 +8117,14 @@ +@@ -7469,10 +8131,14 @@ ) -> None: ''' :param bar: @@ -17195,7 +17210,7 @@ exports[`Generated code for "jsii-calc": /python/src/js } if foo is not None: self._values["foo"] = foo -@@ -7495,10 +8161,13 @@ +@@ -7509,10 +8175,13 @@ def __init__(self, delegate: typing.Mapping[builtins.str, typing.Any]) -> None: ''' @@ -17209,7 +17224,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.python.classproperty @jsii.member(jsii_name="reflector") def REFLECTOR(cls) -> _scope_jsii_calc_lib_custom_submodule_name_c61f082f.Reflector: -@@ -7541,10 +8210,13 @@ +@@ -7555,10 +8224,13 @@ ): def __init__(self, obj: IInterfaceWithProperties) -> None: ''' @@ -17223,7 +17238,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="justRead") def just_read(self) -> builtins.str: return typing.cast(builtins.str, jsii.invoke(self, "justRead", [])) -@@ -7555,17 +8227,23 @@ +@@ -7569,17 +8241,23 @@ ext: IInterfaceWithPropertiesExtension, ) -> builtins.str: ''' @@ -17247,7 +17262,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="obj") def obj(self) -> IInterfaceWithProperties: -@@ -7575,25 +8253,34 @@ +@@ -7589,25 +8267,34 @@ class VariadicInvoker(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.VariadicInvoker"): def __init__(self, method: "VariadicMethod") -> None: ''' @@ -17282,7 +17297,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="asArray") def as_array( self, -@@ -7602,10 +8289,14 @@ +@@ -7616,10 +8303,14 @@ ) -> typing.List[jsii.Number]: ''' :param first: the first element of the array to be returned (after the \`\`prefix\`\` provided at construction time). @@ -17297,7 +17312,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class VariadicTypeUnion( metaclass=jsii.JSIIMeta, -@@ -7613,19 +8304,25 @@ +@@ -7627,19 +8318,25 @@ ): def __init__(self, *union: typing.Union[StructA, StructB]) -> None: ''' @@ -17323,7 +17338,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class VirtualMethodPlayground( metaclass=jsii.JSIIMeta, -@@ -7637,38 +8334,53 @@ +@@ -7651,38 +8348,53 @@ @jsii.member(jsii_name="overrideMeAsync") def override_me_async(self, index: jsii.Number) -> jsii.Number: ''' @@ -17377,7 +17392,7 @@ exports[`Generated code for "jsii-calc": /python/src/js class VoidCallback( metaclass=jsii.JSIIAbstractClass, -@@ -7716,10 +8428,13 @@ +@@ -7730,10 +8442,13 @@ def __init__(self, private_field: typing.Optional[builtins.str] = None) -> None: ''' @@ -17391,7 +17406,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="success") def success(self) -> builtins.bool: -@@ -7760,10 +8475,13 @@ +@@ -7774,10 +8489,13 @@ @jsii.member(jsii_name="abstractMethod") def abstract_method(self, name: builtins.str) -> builtins.str: ''' @@ -17405,7 +17420,7 @@ exports[`Generated code for "jsii-calc": /python/src/js # Adding a "__jsii_proxy_class__(): typing.Type" function to the abstract class typing.cast(typing.Any, AbstractClass).__jsii_proxy_class__ = lambda : _AbstractClassProxy -@@ -7779,10 +8497,14 @@ +@@ -7793,10 +8511,14 @@ '''Creates a BinaryOperation. :param lhs: Left-hand side operand. @@ -17420,7 +17435,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="toString") def to_string(self) -> builtins.str: '''String representation of the value.''' -@@ -7826,10 +8548,13 @@ +@@ -7840,10 +8562,13 @@ def rung(self) -> builtins.bool: return typing.cast(builtins.bool, jsii.get(self, "rung")) @@ -17434,7 +17449,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.data_type( jsii_type="jsii-calc.ChildStruct982", -@@ -7840,10 +8565,14 @@ +@@ -7854,10 +8579,14 @@ def __init__(self, *, foo: builtins.str, bar: jsii.Number) -> None: ''' :param foo: @@ -17449,7 +17464,7 @@ exports[`Generated code for "jsii-calc": /python/src/js "bar": bar, } -@@ -7884,37 +8613,49 @@ +@@ -7898,37 +8627,49 @@ def a(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "a")) @@ -17499,7 +17514,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.implements(INonInternalInterface) class ClassThatImplementsThePrivateInterface( -@@ -7929,37 +8670,49 @@ +@@ -7943,37 +8684,49 @@ def a(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "a")) @@ -17549,7 +17564,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.implements(IInterfaceWithProperties) class ClassWithPrivateConstructorAndAutomaticProperties( -@@ -7977,10 +8730,14 @@ +@@ -7991,10 +8744,14 @@ ) -> "ClassWithPrivateConstructorAndAutomaticProperties": ''' :param read_only_string: - @@ -17564,7 +17579,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="readOnlyString") def read_only_string(self) -> builtins.str: -@@ -7991,10 +8748,13 @@ +@@ -8005,10 +8762,13 @@ def read_write_string(self) -> builtins.str: return typing.cast(builtins.str, jsii.get(self, "readWriteString")) @@ -17578,7 +17593,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.implements(IIndirectlyImplemented) class FullCombo(BaseClass, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.FullCombo"): -@@ -8109,10 +8869,13 @@ +@@ -8123,10 +8883,13 @@ ): def __init__(self, property: builtins.str) -> None: ''' @@ -17592,7 +17607,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="bar") def bar(self) -> None: return typing.cast(None, jsii.invoke(self, "bar", [])) -@@ -8133,10 +8896,13 @@ +@@ -8147,10 +8910,13 @@ def __init__(self, operand: _scope_jsii_calc_lib_c61f082f.NumericValue) -> None: ''' @@ -17606,7 +17621,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @jsii.member(jsii_name="farewell") def farewell(self) -> builtins.str: '''Say farewell.''' -@@ -8196,10 +8962,16 @@ +@@ -8210,10 +8976,16 @@ :param id: some identifier. :param default_bar: the default value of \`\`bar\`\`. :param props: some props once can provide. @@ -17623,7 +17638,7 @@ exports[`Generated code for "jsii-calc": /python/src/js @builtins.property @jsii.member(jsii_name="id") def id(self) -> jsii.Number: -@@ -8494,5 +9266,1522 @@ +@@ -8509,5 +9281,1522 @@ from . import nodirect from . import onlystatic from . import python_self 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 5472af4fe2..510a363362 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap @@ -1988,6 +1988,14 @@ exports[`jsii-tree --all 1`] = ` │ │ └─┬ pow property (stable) │ │ ├── immutable │ │ └── type: @scope/jsii-calc-lib.NumericValue + │ ├─┬ class PromiseNothing (stable) + │ │ └─┬ members + │ │ ├── () initializer (stable) + │ │ ├─┬ static promiseIt() method (stable) + │ │ │ ├── static + │ │ │ └── returns: Promise + │ │ └─┬ instancePromiseIt() method (stable) + │ │ └── returns: Promise │ ├─┬ class PropertyNamedProperty (stable) │ │ └─┬ members │ │ ├── () initializer (stable) @@ -3959,6 +3967,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├── class Polymorphism │ ├─┬ class Power │ │ └── base: CompositeOperation + │ ├── class PromiseNothing │ ├── class PropertyNamedProperty │ ├── class PublicClass │ ├── class PythonReservedWords @@ -5116,6 +5125,11 @@ exports[`jsii-tree --members 1`] = ` │ │ ├── base property │ │ ├── expression property │ │ └── pow property + │ ├─┬ class PromiseNothing + │ │ └─┬ members + │ │ ├── () initializer + │ │ ├── static promiseIt() method + │ │ └── instancePromiseIt() method │ ├─┬ class PropertyNamedProperty │ │ └─┬ members │ │ ├── () initializer @@ -6143,6 +6157,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── class PartiallyInitializedThisConsumer │ ├── class Polymorphism │ ├── class Power + │ ├── class PromiseNothing │ ├── class PropertyNamedProperty │ ├── class PublicClass │ ├── class PythonReservedWords diff --git a/packages/jsii-reflect/test/__snapshots__/tree.test.js.snap b/packages/jsii-reflect/test/__snapshots__/tree.test.js.snap index cdca591c74..1a32ce9fad 100644 --- a/packages/jsii-reflect/test/__snapshots__/tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/tree.test.js.snap @@ -2165,6 +2165,14 @@ exports[`showAll 1`] = ` │ │ └─┬ pow property │ │ ├── immutable │ │ └── type: @scope/jsii-calc-lib.NumericValue + │ ├─┬ class PromiseNothing + │ │ └─┬ members + │ │ ├── () initializer + │ │ ├─┬ static promiseIt() method + │ │ │ ├── static + │ │ │ └── returns: Promise + │ │ └─┬ instancePromiseIt() method + │ │ └── returns: Promise │ ├─┬ class PropertyNamedProperty │ │ └─┬ members │ │ ├── () initializer @@ -4134,6 +4142,7 @@ exports[`types 1`] = ` │ ├── class PartiallyInitializedThisConsumer │ ├── class Polymorphism │ ├── class Power + │ ├── class PromiseNothing │ ├── class PropertyNamedProperty │ ├── class PublicClass │ ├── class PythonReservedWords 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 044c846666..aa57f8639a 100644 --- a/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap @@ -123,6 +123,7 @@ exports[`TypeSystem.classes lists all the classes in the typesystem 1`] = ` "jsii-calc.PartiallyInitializedThisConsumer", "jsii-calc.Polymorphism", "jsii-calc.Power", + "jsii-calc.PromiseNothing", "jsii-calc.PropertyNamedProperty", "jsii-calc.PublicClass", "jsii-calc.PythonReservedWords", diff --git a/tools/jsii-compliance/suite.ts b/tools/jsii-compliance/suite.ts index cedef19235..4a482e0df1 100644 --- a/tools/jsii-compliance/suite.ts +++ b/tools/jsii-compliance/suite.ts @@ -526,5 +526,9 @@ export const suite: schema.Suite = { description: 'Verifies that custom exception names are correctly forwarded', }, + { + name: 'voidReturningAsync', + description: 'Verifies that returning Promise is correctly handled', + }, ], };