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 bf43ec8470..a45d5a4ad9 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 @@ -1387,5 +1387,16 @@ public IStructB ReturnStruct() return Struct; } } + + [Fact(DisplayName = Prefix + nameof(LiftedKwargWithSameNameAsPositionalArg))] + public void LiftedKwargWithSameNameAsPositionalArg() + { + // This is a replication of a test that mostly affects languages with keyword arguments (e.g: Python, Ruby, ...) + var bell = new Bell(); + var amb = new AmbiguousParameters(bell, new StructParameterType { Scope = "Driiiing!" }); + + Assert.Equal(bell, amb.Scope); + Assert.Equal("Driiiing!", amb.Props.Scope); + } } } 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 8bc34c7bc3..aa812e37c0 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 @@ -1658,4 +1658,13 @@ public StructB returnStruct() { return this.struct; } } + + @Test + public void liftedKwargWithSameNameAsPositionalArg() { + // This is a replication of a test that mostly affects languages with keyword arguments (e.g: Python, Ruby, ...) + final Bell bell = new Bell(); + final AmbiguousParameters amb = AmbiguousParameters.Builder.create(bell).scope("Driiiing!").build(); + assertEquals(bell, amb.getScope()); + assertEquals(StructParameterType.builder().scope("Driiiing!").build(), amb.getProps()); + } } diff --git a/packages/@jsii/python-runtime/tests/test_compliance.py b/packages/@jsii/python-runtime/tests/test_compliance.py index 4c0c39154a..6f1a148250 100644 --- a/packages/@jsii/python-runtime/tests/test_compliance.py +++ b/packages/@jsii/python-runtime/tests/test_compliance.py @@ -13,7 +13,9 @@ Add, AllTypes, AllTypesEnum, + AmbiguousParameters, AsyncVirtualMethods, + Bell, Calculator, ClassWithPrivateConstructorAndAutomaticProperties, ConfusingToJackson, @@ -65,6 +67,7 @@ StructB, StructUnionConsumer, SomeTypeJsii976, + StructParameterType, AnonymousImplementationProvider, IAnonymousImplementationProvider ) @@ -1121,3 +1124,10 @@ def return_struct(self): delegate = ImplementsAdditionalInterface() consumer = ConsumePureInterface(delegate) assert consumer.work_it_baby() == expected + +def test_lifted_kwarg_with_same_name_as_positional_arg(): + bell = Bell() + amb = AmbiguousParameters(bell, scope='Driiiing!') + + assert amb.scope == bell + assert amb.props == StructParameterType(scope='Driiiing!') diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index ae85c626f4..ebea26953f 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -2410,3 +2410,18 @@ export class ConsumePureInterface { return this.delegate.returnStruct(); } } + +/** + * Verifies that, in languages that do keyword lifting (e.g: Python), having a + * struct member with the same name as a positional parameter results in the + * correct code being emitted. + * + * See: https://github.com/aws/aws-cdk/issues/4302 + */ +export interface StructParameterType { + readonly scope: string; + readonly props?: boolean; +} +export class AmbiguousParameters { + public constructor(public readonly scope: Bell, public readonly props: StructParameterType) { } +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 14845efc17..d407e42885 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -1027,6 +1027,68 @@ ], "name": "AllowedMethodNames" }, + "jsii-calc.AmbiguousParameters": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.AmbiguousParameters", + "initializer": { + "docs": { + "stability": "experimental" + }, + "parameters": [ + { + "name": "scope", + "type": { + "fqn": "jsii-calc.Bell" + } + }, + { + "name": "props", + "type": { + "fqn": "jsii-calc.StructParameterType" + } + } + ] + }, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2425 + }, + "name": "AmbiguousParameters", + "properties": [ + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2426 + }, + "name": "props", + "type": { + "fqn": "jsii-calc.StructParameterType" + } + }, + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2426 + }, + "name": "scope", + "type": { + "fqn": "jsii-calc.Bell" + } + } + ] + }, "jsii-calc.AnonymousImplementationProvider": { "assembly": "jsii-calc", "docs": { @@ -10049,6 +10111,55 @@ } ] }, + "jsii-calc.StructParameterType": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "remarks": "See: https://github.com/aws/aws-cdk/issues/4302", + "stability": "experimental", + "summary": "Verifies that, in languages that do keyword lifting (e.g: Python), having a struct member with the same name as a positional parameter results in the correct code being emitted." + }, + "fqn": "jsii-calc.StructParameterType", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2421 + }, + "name": "StructParameterType", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2422 + }, + "name": "scope", + "type": { + "primitive": "string" + } + }, + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2423 + }, + "name": "props", + "optional": true, + "type": { + "primitive": "boolean" + } + } + ] + }, "jsii-calc.StructPassing": { "assembly": "jsii-calc", "docs": { @@ -11748,5 +11859,5 @@ } }, "version": "0.20.8", - "fingerprint": "sZ6Jp7HsZKHGh8JYB08PYxyFX0bYBgK1FMDhzjtPjVQ=" + "fingerprint": "4Bqzy6fanRSSO2qQVmaQtsFCqqZVG+7rA/YXuHTbAec=" } diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 4f5db7c579..256c293ffd 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -110,9 +110,26 @@ const toPythonPropertyName = (name: string, constant = false, protectedItem = fa return value; }; -const toPythonParameterName = (name: string): string => { - return toPythonIdentifier(toSnakeCase(name)); -}; +/** + * Converts a given signature's parameter name to what should be emitted in Python. It slugifies the + * positional parameter names that collide with a lifted prop by appending trailing `_`. There is no + * risk of conflicting with an other positional parameter that ends with a `_` character because + * this is prohibited by the `jsii` compiler (parameter names MUST be camelCase, and only a single + * `_` is permitted when it is on **leading** position) + * + * @param name the name of the parameter that needs conversion. + * @param liftedParamNames the list of "lifted" keyword parameters in this signature. This must be + * omitted when generating a name for a parameter that **is** lifted. + */ +function toPythonParameterName(name: string, liftedParamNames = new Set()): string { + let result = toPythonIdentifier(toSnakeCase(name)); + + while (liftedParamNames.has(result)) { + result += '_'; + } + + return result; +} const setDifference = (setA: Set, setB: Set): Set => { const difference = new Set(setA); @@ -339,10 +356,7 @@ abstract class BaseMethod implements PythonBase { // initializers, because our keyword lifting will allow two names to clash. // This can hopefully be removed once we get https://github.com/aws/jsii/issues/288 // resolved. - let paramName: string = toPythonParameterName(param.name); - while (liftedPropNames.has(paramName)) { - paramName = `${paramName}_`; - } + const paramName: string = toPythonParameterName(param.name, liftedPropNames); const paramType = resolver.resolve(param, { forwardReferences: false }); const paramDefault = param.optional ? '=None' : ''; @@ -350,7 +364,10 @@ abstract class BaseMethod implements PythonBase { pythonParams.push(`${paramName}: ${paramType}${paramDefault}`); } - const documentableArgs = [...this.parameters]; + const documentableArgs = this.parameters + // If there's liftedProps, the last argument is the struct and it won't be _actually_ emitted. + .filter((_, index) => this.liftedProp != null ? index < this.parameters.length - 1 : true) + .map(param => ({ ...param, name: toPythonParameterName(param.name, liftedPropNames) })); // If we have a lifted parameter, then we'll drop the last argument to our params // and then we'll lift all of the params of the lifted type as keyword arguments @@ -407,25 +424,31 @@ abstract class BaseMethod implements PythonBase { code.openBlock(`def ${this.pythonName}(${pythonParams.join(', ')}) -> ${returnType}`); this.generator.emitDocString(code, this.docs, { arguments: documentableArgs, documentableItem: `method-${this.pythonName}` }); - this.emitBody(code, resolver, renderAbstract, forceEmitBody); + this.emitBody(code, resolver, renderAbstract, forceEmitBody, liftedPropNames); code.closeBlock(); } - private emitBody(code: CodeMaker, resolver: TypeResolver, renderAbstract: boolean, forceEmitBody: boolean) { + private emitBody( + code: CodeMaker, + resolver: TypeResolver, + renderAbstract: boolean, + forceEmitBody: boolean, + liftedPropNames: Set + ) { if ((!this.shouldEmitBody && !forceEmitBody) || (renderAbstract && this.abstract)) { code.line('...'); } else { if (this.liftedProp !== undefined) { - this.emitAutoProps(code, resolver); + this.emitAutoProps(code, resolver, liftedPropNames); } - this.emitJsiiMethodCall(code, resolver); + this.emitJsiiMethodCall(code, resolver, liftedPropNames); } } - private emitAutoProps(code: CodeMaker, resolver: TypeResolver) { + private emitAutoProps(code: CodeMaker, resolver: TypeResolver, liftedPropNames: Set) { const lastParameter = this.parameters.slice(-1)[0]; - const argName = toPythonParameterName(lastParameter.name); + const argName = toPythonParameterName(lastParameter.name, liftedPropNames); const typeName = resolver.resolve(lastParameter, { ignoreOptional: true }); // We need to build up a list of properties, which are mandatory, these are the @@ -439,7 +462,7 @@ abstract class BaseMethod implements PythonBase { code.line(); } - private emitJsiiMethodCall(code: CodeMaker, resolver: TypeResolver) { + private emitJsiiMethodCall(code: CodeMaker, resolver: TypeResolver, liftedPropNames: Set) { const methodPrefix: string = this.returnFromJSIIMethod ? 'return ' : ''; const jsiiMethodParams: string[] = []; @@ -457,7 +480,7 @@ abstract class BaseMethod implements PythonBase { // If the last arg is variadic, expand the tuple const params: string[] = []; for (const param of this.parameters) { - let expr = toPythonParameterName(param.name); + let expr = toPythonParameterName(param.name, liftedPropNames); if (param.variadic) { expr = `*${expr}`; } params.push(expr); } @@ -1502,10 +1525,14 @@ class PythonGenerator extends Generator { this.types = new Map(); } - public emitDocString(code: CodeMaker, docs: spec.Docs | undefined, options: { - arguments?: DocumentableArgument[]; - documentableItem?: string; - } = {}) { + public emitDocString( + code: CodeMaker, + docs: spec.Docs | undefined, + options: { + arguments?: DocumentableArgument[]; + documentableItem?: string; + } = {} + ) { if ((!docs || Object.keys(docs).length === 0) && !options.arguments) { return; } if (!docs) { docs = {}; } 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 14845efc17..d407e42885 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 @@ -1027,6 +1027,68 @@ ], "name": "AllowedMethodNames" }, + "jsii-calc.AmbiguousParameters": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.AmbiguousParameters", + "initializer": { + "docs": { + "stability": "experimental" + }, + "parameters": [ + { + "name": "scope", + "type": { + "fqn": "jsii-calc.Bell" + } + }, + { + "name": "props", + "type": { + "fqn": "jsii-calc.StructParameterType" + } + } + ] + }, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2425 + }, + "name": "AmbiguousParameters", + "properties": [ + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2426 + }, + "name": "props", + "type": { + "fqn": "jsii-calc.StructParameterType" + } + }, + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2426 + }, + "name": "scope", + "type": { + "fqn": "jsii-calc.Bell" + } + } + ] + }, "jsii-calc.AnonymousImplementationProvider": { "assembly": "jsii-calc", "docs": { @@ -10049,6 +10111,55 @@ } ] }, + "jsii-calc.StructParameterType": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "remarks": "See: https://github.com/aws/aws-cdk/issues/4302", + "stability": "experimental", + "summary": "Verifies that, in languages that do keyword lifting (e.g: Python), having a struct member with the same name as a positional parameter results in the correct code being emitted." + }, + "fqn": "jsii-calc.StructParameterType", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2421 + }, + "name": "StructParameterType", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2422 + }, + "name": "scope", + "type": { + "primitive": "string" + } + }, + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2423 + }, + "name": "props", + "optional": true, + "type": { + "primitive": "boolean" + } + } + ] + }, "jsii-calc.StructPassing": { "assembly": "jsii-calc", "docs": { @@ -11748,5 +11859,5 @@ } }, "version": "0.20.8", - "fingerprint": "sZ6Jp7HsZKHGh8JYB08PYxyFX0bYBgK1FMDhzjtPjVQ=" + "fingerprint": "4Bqzy6fanRSSO2qQVmaQtsFCqqZVG+7rA/YXuHTbAec=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AmbiguousParameters.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AmbiguousParameters.cs new file mode 100644 index 0000000000..85105bbd92 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/AmbiguousParameters.cs @@ -0,0 +1,44 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// + /// stability: Experimental + /// + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.AmbiguousParameters), fullyQualifiedName: "jsii-calc.AmbiguousParameters", parametersJson: "[{\"name\":\"scope\",\"type\":{\"fqn\":\"jsii-calc.Bell\"}},{\"name\":\"props\",\"type\":{\"fqn\":\"jsii-calc.StructParameterType\"}}]")] + public class AmbiguousParameters : DeputyBase + { + /// + /// stability: Experimental + /// + public AmbiguousParameters(Amazon.JSII.Tests.CalculatorNamespace.Bell scope, Amazon.JSII.Tests.CalculatorNamespace.IStructParameterType props): base(new DeputyProps(new object[]{scope, props})) + { + } + + protected AmbiguousParameters(ByRefValue reference): base(reference) + { + } + + protected AmbiguousParameters(DeputyProps props): base(props) + { + } + + /// + /// stability: Experimental + /// + [JsiiProperty(name: "props", typeJson: "{\"fqn\":\"jsii-calc.StructParameterType\"}")] + public virtual Amazon.JSII.Tests.CalculatorNamespace.IStructParameterType Props + { + get => GetInstanceProperty(); + } + + /// + /// stability: Experimental + /// + [JsiiProperty(name: "scope", typeJson: "{\"fqn\":\"jsii-calc.Bell\"}")] + public virtual Amazon.JSII.Tests.CalculatorNamespace.Bell Scope + { + get => GetInstanceProperty(); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStructParameterType.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStructParameterType.cs new file mode 100644 index 0000000000..4de949264b --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IStructParameterType.cs @@ -0,0 +1,35 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Verifies that, in languages that do keyword lifting (e.g: Python), having a struct member with the same name as a positional parameter results in the correct code being emitted. + /// + /// See: https://github.com/aws/aws-cdk/issues/4302 + /// stability: Experimental + /// + [JsiiInterface(nativeType: typeof(IStructParameterType), fullyQualifiedName: "jsii-calc.StructParameterType")] + public interface IStructParameterType + { + /// + /// stability: Experimental + /// + [JsiiProperty(name: "scope", typeJson: "{\"primitive\":\"string\"}")] + string Scope + { + get; + } + + /// + /// stability: Experimental + /// + [JsiiProperty(name: "props", typeJson: "{\"primitive\":\"boolean\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] + bool? Props + { + get + { + return null; + } + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StructParameterType.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StructParameterType.cs new file mode 100644 index 0000000000..80166d351a --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StructParameterType.cs @@ -0,0 +1,34 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Verifies that, in languages that do keyword lifting (e.g: Python), having a struct member with the same name as a positional parameter results in the correct code being emitted. + /// + /// See: https://github.com/aws/aws-cdk/issues/4302 + /// stability: Experimental + /// + [JsiiByValue(fqn: "jsii-calc.StructParameterType")] + public class StructParameterType : Amazon.JSII.Tests.CalculatorNamespace.IStructParameterType + { + /// + /// stability: Experimental + /// + [JsiiProperty(name: "scope", typeJson: "{\"primitive\":\"string\"}", isOverride: true)] + public string Scope + { + get; + set; + } + + /// + /// stability: Experimental + /// + [JsiiOptional] + [JsiiProperty(name: "props", typeJson: "{\"primitive\":\"boolean\"}", isOptional: true, isOverride: true)] + public bool? Props + { + get; + set; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StructParameterTypeProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StructParameterTypeProxy.cs new file mode 100644 index 0000000000..a06b25451d --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/StructParameterTypeProxy.cs @@ -0,0 +1,36 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Verifies that, in languages that do keyword lifting (e.g: Python), having a struct member with the same name as a positional parameter results in the correct code being emitted. + /// + /// See: https://github.com/aws/aws-cdk/issues/4302 + /// stability: Experimental + /// + [JsiiTypeProxy(nativeType: typeof(IStructParameterType), fullyQualifiedName: "jsii-calc.StructParameterType")] + internal sealed class StructParameterTypeProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.IStructParameterType + { + private StructParameterTypeProxy(ByRefValue reference): base(reference) + { + } + + /// + /// stability: Experimental + /// + [JsiiProperty(name: "scope", typeJson: "{\"primitive\":\"string\"}")] + public string Scope + { + get => GetInstanceProperty(); + } + + /// + /// stability: Experimental + /// + [JsiiOptional] + [JsiiProperty(name: "props", typeJson: "{\"primitive\":\"boolean\"}", isOptional: true)] + public bool? Props + { + get => GetInstanceProperty(); + } + } +} 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 cfff0482da..786f98a403 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 @@ -25,6 +25,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.AllTypes": return software.amazon.jsii.tests.calculator.AllTypes.class; case "jsii-calc.AllTypesEnum": return software.amazon.jsii.tests.calculator.AllTypesEnum.class; case "jsii-calc.AllowedMethodNames": return software.amazon.jsii.tests.calculator.AllowedMethodNames.class; + case "jsii-calc.AmbiguousParameters": return software.amazon.jsii.tests.calculator.AmbiguousParameters.class; case "jsii-calc.AnonymousImplementationProvider": return software.amazon.jsii.tests.calculator.AnonymousImplementationProvider.class; case "jsii-calc.AsyncVirtualMethods": return software.amazon.jsii.tests.calculator.AsyncVirtualMethods.class; case "jsii-calc.AugmentableClass": return software.amazon.jsii.tests.calculator.AugmentableClass.class; @@ -177,6 +178,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.StripInternal": return software.amazon.jsii.tests.calculator.StripInternal.class; case "jsii-calc.StructA": return software.amazon.jsii.tests.calculator.StructA.class; case "jsii-calc.StructB": return software.amazon.jsii.tests.calculator.StructB.class; + case "jsii-calc.StructParameterType": return software.amazon.jsii.tests.calculator.StructParameterType.class; case "jsii-calc.StructPassing": return software.amazon.jsii.tests.calculator.StructPassing.class; case "jsii-calc.StructUnionConsumer": return software.amazon.jsii.tests.calculator.StructUnionConsumer.class; case "jsii-calc.StructWithJavaReservedWords": return software.amazon.jsii.tests.calculator.StructWithJavaReservedWords.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AmbiguousParameters.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AmbiguousParameters.java new file mode 100644 index 0000000000..9284cd2c80 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/AmbiguousParameters.java @@ -0,0 +1,106 @@ +package software.amazon.jsii.tests.calculator; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.AmbiguousParameters") +public class AmbiguousParameters extends software.amazon.jsii.JsiiObject { + + protected AmbiguousParameters(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected AmbiguousParameters(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + * EXPERIMENTAL + * + * @param scope This parameter is required. + * @param props This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public AmbiguousParameters(final software.amazon.jsii.tests.calculator.Bell scope, final software.amazon.jsii.tests.calculator.StructParameterType props) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(props, "props is required") }); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public software.amazon.jsii.tests.calculator.StructParameterType getProps() { + return this.jsiiGet("props", software.amazon.jsii.tests.calculator.StructParameterType.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public software.amazon.jsii.tests.calculator.Bell getScope() { + return this.jsiiGet("scope", software.amazon.jsii.tests.calculator.Bell.class); + } + + /** + * A fluent builder for {@link software.amazon.jsii.tests.calculator.AmbiguousParameters}. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static final class Builder { + /** + * EXPERIMENTAL + * + * @return a new instance of {@link Builder}. + * @param scope This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static Builder create(final software.amazon.jsii.tests.calculator.Bell scope) { + return new Builder(scope); + } + + private final software.amazon.jsii.tests.calculator.Bell scope; + private final software.amazon.jsii.tests.calculator.StructParameterType.Builder props; + + private Builder(final software.amazon.jsii.tests.calculator.Bell scope) { + this.scope = scope; + this.props = new software.amazon.jsii.tests.calculator.StructParameterType.Builder(); + } + + /** + * EXPERIMENTAL + * + * @return {@code this} + * @param scope This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public Builder scope(final java.lang.String scope) { + this.props.scope(scope); + return this; + } + + /** + * EXPERIMENTAL + * + * @return {@code this} + * @param props This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public Builder props(final java.lang.Boolean props) { + this.props.props(props); + return this; + } + + /** + * @returns a newly built instance of {@link software.amazon.jsii.tests.calculator.AmbiguousParameters}. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public software.amazon.jsii.tests.calculator.AmbiguousParameters build() { + return new software.amazon.jsii.tests.calculator.AmbiguousParameters( + this.scope, + this.props.build() + ); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StructParameterType.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StructParameterType.java new file mode 100644 index 0000000000..9204d3c1fb --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/StructParameterType.java @@ -0,0 +1,153 @@ +package software.amazon.jsii.tests.calculator; + +/** + * Verifies that, in languages that do keyword lifting (e.g: Python), having a struct member with the same name as a positional parameter results in the correct code being emitted. + * + *

See: https://github.com/aws/aws-cdk/issues/4302

+ * + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.StructParameterType") +@software.amazon.jsii.Jsii.Proxy(StructParameterType.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +public interface StructParameterType extends software.amazon.jsii.JsiiSerializable { + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + java.lang.String getScope(); + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + default java.lang.Boolean getProps() { + return null; + } + + /** + * @return a {@link Builder} of {@link StructParameterType} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link StructParameterType} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static final class Builder { + private java.lang.String scope; + private java.lang.Boolean props; + + /** + * Sets the value of {@link StructParameterType#getScope} + * @param scope the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public Builder scope(java.lang.String scope) { + this.scope = scope; + return this; + } + + /** + * Sets the value of {@link StructParameterType#getProps} + * @param props the value to be set. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public Builder props(java.lang.Boolean props) { + this.props = props; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link StructParameterType} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public StructParameterType build() { + return new Jsii$Proxy(scope, props); + } + } + + /** + * An implementation for {@link StructParameterType} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements StructParameterType { + private final java.lang.String scope; + private final java.lang.Boolean props; + + /** + * Constructor that initializes the object based on values retrieved from the JsiiObject. + * @param objRef Reference to the JSII managed object. + */ + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + this.scope = this.jsiiGet("scope", java.lang.String.class); + this.props = this.jsiiGet("props", java.lang.Boolean.class); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + private Jsii$Proxy(final java.lang.String scope, final java.lang.Boolean props) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.scope = java.util.Objects.requireNonNull(scope, "scope is required"); + this.props = props; + } + + @Override + public java.lang.String getScope() { + return this.scope; + } + + @Override + public java.lang.Boolean getProps() { + return this.props; + } + + @Override + public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { + final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; + final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + + data.set("scope", om.valueToTree(this.getScope())); + if (this.getProps() != null) { + data.set("props", om.valueToTree(this.getProps())); + } + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("jsii-calc.StructParameterType")); + struct.set("data", data); + + final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + obj.set("$jsii.struct", struct); + + return obj; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + StructParameterType.Jsii$Proxy that = (StructParameterType.Jsii$Proxy) o; + + if (!scope.equals(that.scope)) return false; + return this.props != null ? this.props.equals(that.props) : that.props == null; + } + + @Override + public int hashCode() { + int result = this.scope.hashCode(); + result = 31 * result + (this.props != null ? this.props.hashCode() : 0); + return result; + } + } +} 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 d887035f34..d60531b5af 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 @@ -468,6 +468,43 @@ def set_foo(self, _x: str, _y: jsii.Number) -> None: return jsii.invoke(self, "setFoo", [_x, _y]) +class AmbiguousParameters(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AmbiguousParameters"): + """ + stability + :stability: experimental + """ + def __init__(self, scope_: "Bell", *, scope: str, props: typing.Optional[bool]=None) -> None: + """ + :param scope_: - + :param scope: + :param props: + + stability + :stability: experimental + """ + props_ = StructParameterType(scope=scope, props=props) + + jsii.create(AmbiguousParameters, self, [scope_, props_]) + + @property + @jsii.member(jsii_name="props") + def props(self) -> "StructParameterType": + """ + stability + :stability: experimental + """ + return jsii.get(self, "props") + + @property + @jsii.member(jsii_name="scope") + def scope(self) -> "Bell": + """ + stability + :stability: experimental + """ + return jsii.get(self, "scope") + + class AsyncVirtualMethods(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AsyncVirtualMethods"): """ stability @@ -1219,7 +1256,6 @@ def __init__(self) -> None: @jsii.member(jsii_name="render") def render(self, *, anumber: jsii.Number, astring: str, first_optional: typing.Optional[typing.List[str]]=None) -> str: """ - :param data: - :param anumber: An awesome number value. :param astring: A string value. :param first_optional: @@ -1888,7 +1924,6 @@ def greet(self, *, name: typing.Optional[str]=None) -> jsii.Number: This will print out a friendly greeting intended for the indicated person. - :param greetee: The person to be greeted. :param name: The name of the greetee. Default: world return @@ -2209,7 +2244,6 @@ def __init__(self) -> None: def derived_to_first(self, *, another_required: datetime.datetime, bool: bool, non_primitive: "DoubleTrouble", another_optional: typing.Optional[typing.Mapping[str,scope.jsii_calc_lib.Value]]=None, optional_any: typing.Any=None, optional_array: typing.Optional[typing.List[str]]=None, anumber: jsii.Number, astring: str, first_optional: typing.Optional[typing.List[str]]=None) -> scope.jsii_calc_lib.MyFirstStruct: """Accepts a struct of type DerivedStruct and returns a struct of type FirstStruct. - :param derived: - :param another_required: :param bool: :param non_primitive: An example of a non primitive property. @@ -2231,7 +2265,6 @@ def derived_to_first(self, *, another_required: datetime.datetime, bool: bool, n def read_derived_non_primitive(self, *, another_required: datetime.datetime, bool: bool, non_primitive: "DoubleTrouble", another_optional: typing.Optional[typing.Mapping[str,scope.jsii_calc_lib.Value]]=None, optional_any: typing.Any=None, optional_array: typing.Optional[typing.List[str]]=None, anumber: jsii.Number, astring: str, first_optional: typing.Optional[typing.List[str]]=None) -> "DoubleTrouble": """Returns the boolean from a DerivedStruct struct. - :param derived: - :param another_required: :param bool: :param non_primitive: An example of a non primitive property. @@ -2253,7 +2286,6 @@ def read_derived_non_primitive(self, *, another_required: datetime.datetime, boo def read_first_number(self, *, anumber: jsii.Number, astring: str, first_optional: typing.Optional[typing.List[str]]=None) -> jsii.Number: """Returns the "anumber" from a MyFirstStruct struct; - :param first: - :param anumber: An awesome number value. :param astring: A string value. :param first_optional: @@ -5453,7 +5485,6 @@ def give_me_undefined(self, value: typing.Any=None) -> None: @jsii.member(jsii_name="giveMeUndefinedInsideAnObject") def give_me_undefined_inside_an_object(self, *, array_with_three_elements_and_undefined_as_second_argument: typing.List[typing.Any], this_should_be_undefined: typing.Any=None) -> None: """ - :param input: - :param array_with_three_elements_and_undefined_as_second_argument: :param this_should_be_undefined: @@ -5756,7 +5787,6 @@ class OptionalStructConsumer(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Optio """ def __init__(self, *, field: typing.Optional[str]=None) -> None: """ - :param optional_struct: - :param field: stability @@ -6414,7 +6444,6 @@ class RootStructValidator(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.RootStru @classmethod def validate(cls, *, string_prop: str, nested_struct: typing.Optional["NestedStruct"]=None) -> None: """ - :param struct: - :param string_prop: May not be empty. :param nested_struct: @@ -6982,6 +7011,50 @@ def __repr__(self) -> str: return 'StructB(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) +@jsii.data_type(jsii_type="jsii-calc.StructParameterType", jsii_struct_bases=[], name_mapping={'scope': 'scope', 'props': 'props'}) +class StructParameterType(): + def __init__(self, *, scope: str, props: typing.Optional[bool]=None): + """Verifies that, in languages that do keyword lifting (e.g: Python), having a struct member with the same name as a positional parameter results in the correct code being emitted. + + See: https://github.com/aws/aws-cdk/issues/4302 + + :param scope: + :param props: + + stability + :stability: experimental + """ + self._values = { + 'scope': scope, + } + if props is not None: self._values["props"] = props + + @property + def scope(self) -> str: + """ + stability + :stability: experimental + """ + return self._values.get('scope') + + @property + def props(self) -> typing.Optional[bool]: + """ + stability + :stability: experimental + """ + return self._values.get('props') + + def __eq__(self, rhs) -> bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs) -> bool: + return not (rhs == self) + + def __repr__(self) -> str: + return 'StructParameterType(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) + + class StructPassing(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StructPassing"): """Just because we can.""" def __init__(self) -> None: @@ -7001,7 +7074,6 @@ def how_many_var_args_did_i_pass(cls, _positional: jsii.Number, *inputs: "TopLev def round_trip(cls, _positional: jsii.Number, *, required: str, second_level: typing.Union[jsii.Number, "SecondLevelStruct"], optional: typing.Optional[str]=None) -> "TopLevelStruct": """ :param _positional: - - :param input: - :param required: This is a required field. :param second_level: A union to really stress test our serialization. :param optional: You don't have to pass this. @@ -7153,8 +7225,7 @@ class SupportsNiceJavaBuilderWithRequiredProps(metaclass=jsii.JSIIMeta, jsii_typ """ def __init__(self, id_: jsii.Number, *, bar: jsii.Number, id: typing.Optional[str]=None) -> None: """ - :param id: some identifier of your choice. - :param props: some properties. + :param id_: some identifier of your choice. :param bar: Some number, like 42. :param id: An ``id`` field here is terrible API design, because the constructor of ``SupportsNiceJavaBuilder`` already has a parameter named ``id``. But here we are, doing it like we didn't care. @@ -7163,7 +7234,7 @@ def __init__(self, id_: jsii.Number, *, bar: jsii.Number, id: typing.Optional[st """ props = SupportsNiceJavaBuilderProps(bar=bar, id=id) - jsii.create(SupportsNiceJavaBuilderWithRequiredProps, self, [id, props]) + jsii.create(SupportsNiceJavaBuilderWithRequiredProps, self, [id_, props]) @property @jsii.member(jsii_name="bar") @@ -8030,7 +8101,6 @@ class Calculator(composition.CompositeOperation, metaclass=jsii.JSIIMeta, jsii_t def __init__(self, *, initial_value: typing.Optional[jsii.Number]=None, maximum_value: typing.Optional[jsii.Number]=None) -> None: """Creates a Calculator object. - :param props: Initialization properties. :param initial_value: The initial value of the calculator. NOTE: Any number works here, it's fine. Default: 0 :param maximum_value: The maximum value the calculator can store. Default: none @@ -8251,6 +8321,6 @@ def parts(self, value: typing.List[scope.jsii_calc_lib.Value]): return jsii.set(self, "parts", value) -__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass", "BaseJsii976", "Bell", "BinaryOperation", "Calculator", "CalculatorProps", "ChildStruct982", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConfusingToJackson", "ConfusingToJacksonStruct", "ConstructorPassesThisOut", "Constructors", "ConsumePureInterface", "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "Demonstrate982", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DisappointingCollectionSource", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IBell", "IBellRinger", "IConcreteBellRinger", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IObjectWithProperty", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnJsii976", "IReturnsNumber", "IStableInterface", "IStructReturningDelegate", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "JsonFormatter", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NestedStruct", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "ObjectWithPropertyProvider", "Old", "OptionalArgumentInvoker", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "ParentStruct982", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RootStruct", "RootStructValidator", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "SomeTypeJsii976", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicInvoker", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] +__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AmbiguousParameters", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass", "BaseJsii976", "Bell", "BinaryOperation", "Calculator", "CalculatorProps", "ChildStruct982", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConfusingToJackson", "ConfusingToJacksonStruct", "ConstructorPassesThisOut", "Constructors", "ConsumePureInterface", "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "Demonstrate982", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DisappointingCollectionSource", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IBell", "IBellRinger", "IConcreteBellRinger", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IObjectWithProperty", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnJsii976", "IReturnsNumber", "IStableInterface", "IStructReturningDelegate", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "JsonFormatter", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NestedStruct", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "ObjectWithPropertyProvider", "Old", "OptionalArgumentInvoker", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "ParentStruct982", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RootStruct", "RootStructValidator", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "SomeTypeJsii976", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructParameterType", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicInvoker", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] publication.publish() diff --git a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap index 1aebc42004..93f3857bc8 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap @@ -140,6 +140,20 @@ exports[`jsii-tree --all 1`] = ` │ │ │ └─┬ _y │ │ │ └── type: number │ │ └── returns: void + │ ├─┬ class AmbiguousParameters (experimental) + │ │ └─┬ members + │ │ ├─┬ (scope,props) initializer (experimental) + │ │ │ └─┬ parameters + │ │ │ ├─┬ scope + │ │ │ │ └── type: jsii-calc.Bell + │ │ │ └─┬ props + │ │ │ └── type: jsii-calc.StructParameterType + │ │ ├─┬ props property (experimental) + │ │ │ ├── immutable + │ │ │ └── type: jsii-calc.StructParameterType + │ │ └─┬ scope property (experimental) + │ │ ├── immutable + │ │ └── type: jsii-calc.Bell │ ├─┬ class AnonymousImplementationProvider (experimental) │ │ ├── interfaces: IAnonymousImplementationProvider │ │ └─┬ members @@ -2112,6 +2126,16 @@ exports[`jsii-tree --all 1`] = ` │ │ ├── abstract │ │ ├── immutable │ │ └── type: Optional + │ ├─┬ interface StructParameterType (experimental) + │ │ └─┬ members + │ │ ├─┬ scope property (experimental) + │ │ │ ├── abstract + │ │ │ ├── immutable + │ │ │ └── type: string + │ │ └─┬ props property (experimental) + │ │ ├── abstract + │ │ ├── immutable + │ │ └── type: Optional │ ├─┬ interface StructWithJavaReservedWords (experimental) │ │ └─┬ members │ │ ├─┬ default property (experimental) @@ -2330,6 +2354,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ │ └── base: BinaryOperation │ ├── class AllTypes │ ├── class AllowedMethodNames + │ ├── class AmbiguousParameters │ ├─┬ class AnonymousImplementationProvider │ │ └── interfaces: IAnonymousImplementationProvider │ ├── class AsyncVirtualMethods @@ -2545,6 +2570,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├── interface StableStruct │ ├── interface StructA │ ├── interface StructB + │ ├── interface StructParameterType │ ├── interface StructWithJavaReservedWords │ ├── interface SupportsNiceJavaBuilderProps │ ├── interface TopLevelStruct @@ -2648,6 +2674,11 @@ exports[`jsii-tree --members 1`] = ` │ │ ├── getFoo(withParam) method │ │ ├── setBar(_x,_y,_z) method │ │ └── setFoo(_x,_y) method + │ ├─┬ class AmbiguousParameters + │ │ └─┬ members + │ │ ├── (scope,props) initializer + │ │ ├── props property + │ │ └── scope property │ ├─┬ class AnonymousImplementationProvider │ │ └─┬ members │ │ ├── () initializer @@ -3502,6 +3533,10 @@ exports[`jsii-tree --members 1`] = ` │ │ ├── requiredString property │ │ ├── optionalBoolean property │ │ └── optionalStructA property + │ ├─┬ interface StructParameterType + │ │ └─┬ members + │ │ ├── scope property + │ │ └── props property │ ├─┬ interface StructWithJavaReservedWords │ │ └─┬ members │ │ ├── default property @@ -3629,6 +3664,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── class Add │ ├── class AllTypes │ ├── class AllowedMethodNames + │ ├── class AmbiguousParameters │ ├── class AnonymousImplementationProvider │ ├── class AsyncVirtualMethods │ ├── class AugmentableClass @@ -3792,6 +3828,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── interface StableStruct │ ├── interface StructA │ ├── interface StructB + │ ├── interface StructParameterType │ ├── interface StructWithJavaReservedWords │ ├── interface SupportsNiceJavaBuilderProps │ ├── interface TopLevelStruct 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 d35df4c33c..16060fbb6e 100644 --- a/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap @@ -17,6 +17,7 @@ Array [ "Add", "AllTypes", "AllowedMethodNames", + "AmbiguousParameters", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass",