From 44282214cf38991c7a1b0f5131a36b94634a35da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Tue, 5 Nov 2019 10:05:47 +0100 Subject: [PATCH 1/8] fix(kernel): revert behavior change around `any` serialization The change of behavior in `any` serialization introduced in #825 risks breaking some emerging use-cases of the AWS CDK that are likely to be prevalent in the installed user base. As a consequence, surgically reverting this particular change in order to restore the behavior that users might be dependent on. This somehow uncovered an outstanding bug in the Python runtime that was not triggering with the "reverted" behavior (it broke unit tests). The runtime was fixed in order to address this bug. --- packages/jsii-kernel/lib/objects.ts | 17 --- packages/jsii-kernel/lib/serialization.ts | 101 ++++++------------ packages/jsii-kernel/test/kernel.test.ts | 22 ++-- .../src/jsii/_reference_map.py | 63 ++++++++--- 4 files changed, 87 insertions(+), 116 deletions(-) diff --git a/packages/jsii-kernel/lib/objects.ts b/packages/jsii-kernel/lib/objects.ts index 620ce94b44..249718e739 100644 --- a/packages/jsii-kernel/lib/objects.ts +++ b/packages/jsii-kernel/lib/objects.ts @@ -58,23 +58,6 @@ function tagObject(obj: object, objid: string, interfaces?: string[]) { managed[IFACES_SYMBOL] = interfaces; } -/** - * Ensure there's a hidden map with the given symbol name on the given object, and return it - */ -export function hiddenMap(obj: any, mapSymbol: symbol): {[key: string]: T} { - let map: any = obj[mapSymbol]; - if (!map) { - map = {}; - Object.defineProperty(obj, mapSymbol, { - value: map, - configurable: false, - enumerable: false, - writable: false - }); - } - return map; -} - /** * Set the JSII FQN for classes produced by a given constructor */ diff --git a/packages/jsii-kernel/lib/serialization.ts b/packages/jsii-kernel/lib/serialization.ts index 64f17adf30..5e5174b6c1 100644 --- a/packages/jsii-kernel/lib/serialization.ts +++ b/packages/jsii-kernel/lib/serialization.ts @@ -28,7 +28,7 @@ import * as spec from 'jsii-spec'; import { isObjRef, isWireDate, isWireEnum, isWireMap, ObjRef, TOKEN_DATE, TOKEN_ENUM, TOKEN_MAP, WireDate, WireEnum } from './api'; -import { hiddenMap, jsiiTypeFqn, objectReference, ObjectTable } from './objects'; +import { jsiiTypeFqn, objectReference, ObjectTable } from './objects'; import { api } from '.'; /** @@ -273,14 +273,6 @@ export const SERIALIZERS: {[k: string]: Serializer} = { throw new Error(`Expected object, got ${JSON.stringify(value)}`); } - // This looks odd, but if an object was originally passed in/out as a by-ref - // class, and it happens to conform to a datatype interface we say we're - // returning, return the actual object instead of the serialized value. - // NOTE: Not entirely sure yet whether this is a bug masquerading as a - // feature or not. - const prevRef = objectReference(value); - if (prevRef) { return prevRef; } - /* This is what we'd like to do, but we can't because at least the Java client does not understand by-value serialized interface types, so we'll have to @@ -298,8 +290,7 @@ export const SERIALIZERS: {[k: string]: Serializer} = { host.debug('Returning value type by reference'); - const wireFqn = selectWireType(value, optionalValue.type as spec.NamedTypeReference, host.lookupType); - return host.objects.registerObject(value, wireFqn); + return host.objects.registerObject(value, 'Object', [(optionalValue.type as spec.NamedTypeReference).fqn]); }, deserialize(value, optionalValue, host) { if (typeof value === 'object' && Object.keys(value || {}).length === 0) { @@ -361,11 +352,13 @@ export const SERIALIZERS: {[k: string]: Serializer} = { throw new Error(`Expected object reference, got ${JSON.stringify(value)}`); } - const prevRef = objectReference(value); - if (prevRef) { return prevRef; } + const expectedType = host.lookupType((optionalValue.type as spec.NamedTypeReference).fqn); + const interfaces = spec.isInterfaceType(expectedType) + ? [expectedType.fqn] + : undefined; + const jsiiType = jsiiTypeFqn(value) || (spec.isClassType(expectedType) ? expectedType.fqn : 'Object'); - const wireFqn = selectWireType(value, optionalValue.type as spec.NamedTypeReference, host.lookupType); - return host.objects.registerObject(value, wireFqn); + return host.objects.registerObject(value, jsiiType, interfaces); }, deserialize(value, optionalValue, host) { if (nullAndOk(value, optionalValue)) { return undefined; } @@ -400,7 +393,7 @@ export const SERIALIZERS: {[k: string]: Serializer} = { // ---------------------------------------------------------------------- [SerializationClass.Any]: { - serialize(value, type, host) { + serialize(value, _type, host) { if (value == null) { return undefined; } if (isDate(value)) { return serializeDate(value); } @@ -412,6 +405,10 @@ export const SERIALIZERS: {[k: string]: Serializer} = { // Note: no case for "ENUM" here, without type declaration we can't tell the difference // between an enum member and a scalar. + if (typeof value === 'function') { + throw new Error('JSII Kernel is unable to serialize `function`. An instance with methods might have been returned by an `any` method?'); + } + if (typeof value !== 'object' || value == null) { throw new Error(`JSII kernel assumption violated, ${JSON.stringify(value)} is not an object`); } @@ -436,12 +433,24 @@ export const SERIALIZERS: {[k: string]: Serializer} = { // way, and the by-value serialized object will be quite useless. if (value instanceof Set || value instanceof Map) { throw new Error("Can't return objects of type Set or Map"); } - // Pass-by-reference, so we're sure we don't end up doing anything unexpected - const jsiiType = jsiiTypeFqn(value) || EMPTY_OBJECT_FQN; - const interfaces = type !== 'void' && spec.isNamedTypeReference(type.type) - ? [type.type.fqn] - : undefined; - return host.objects.registerObject(value, jsiiType, interfaces); + // Use a previous reference to maintain object identity. NOTE: this may cause us to return + // a different type than requested! This is just how it is right now. + // https://github.com/aws/jsii/issues/399 + const prevRef = objectReference(value); + if (prevRef) { return prevRef; } + + // If this is or should be a reference type, pass or make the reference + // (Like regular reftype serialization, but without the type derivation to an interface) + const jsiiType = jsiiTypeFqn(value); + if (jsiiType) { return host.objects.registerObject(value, jsiiType); } + + // At this point we have an object that is not of an exported type. Either an object + // literal, or an instance of a fully private class (cannot distinguish those cases). + + // We will serialize by-value, but recurse for serialization so that if + // the object contains reference objects, they will be serialized appropriately. + // (Basically, serialize anything else as a map of 'any'). + return mapValues(value, (v) => host.recurse(v, { type: spec.CANONICAL_ANY })); }, deserialize(value, _type, host) { @@ -561,10 +570,8 @@ export function serializationType(typeRef: OptionalValueOrVoid, lookup: TypeLook return [{ serializationClass: SerializationClass.Enum, typeRef }]; } - if (spec.isInterfaceType(type)) { - return type.datatype - ? [{ serializationClass: SerializationClass.Struct, typeRef }] - : [{ serializationClass: SerializationClass.Any, typeRef }]; + if (spec.isInterfaceType(type) && type.datatype) { + return [{ serializationClass: SerializationClass.Struct, typeRef }]; } return [{ serializationClass: SerializationClass.ReferenceType, typeRef }]; @@ -632,48 +639,6 @@ function propertiesOf(t: spec.Type, lookup: TypeLookup): {[name: string]: spec.P return ret; } -const WIRE_TYPE_MAP = Symbol('$__jsii_wire_type__$'); - -/** - * Select the wire type for the given object and requested type - * - * Should return the most specific type that is in the JSII assembly and - * assignable to the required type. - * - * We actually don't need to search much; because of prototypal constructor - * linking, object.constructor.__jsii__ will have the FQN of the most specific - * exported JSII class this object is an instance of. - * - * Either that's assignable to the requested type, in which case we return it, - * or it's not, in which case there's a hidden class that implements the interface - * and we just return the interface so the other side can instantiate an interface - * proxy for it. - * - * Cache the analysis on the object to avoid having to do too many searches through - * the type system for repeated accesses on the same object. - */ -function selectWireType(obj: any, expectedType: spec.NamedTypeReference, lookup: TypeLookup): string { - const map = hiddenMap(obj, WIRE_TYPE_MAP); - - if (!(expectedType.fqn in map)) { - const jsiiType = jsiiTypeFqn(obj); - if (jsiiType) { - const assignable = isAssignable(jsiiType, expectedType, lookup); - - // If we're not assignable and both types are class types, this cannot be satisfied. - if (!assignable && spec.isClassType(lookup(expectedType.fqn))) { - throw new Error(`Object of type ${jsiiType} is not convertible to ${expectedType.fqn}`); - } - - map[expectedType.fqn] = assignable ? jsiiType : expectedType.fqn; - } else { - map[expectedType.fqn] = expectedType.fqn; - } - } - - return map[expectedType.fqn]; -} - /** * Tests whether a given type (by it's FQN) can be assigned to a named type reference. * diff --git a/packages/jsii-kernel/test/kernel.test.ts b/packages/jsii-kernel/test/kernel.test.ts index 48486251ba..d156392e98 100644 --- a/packages/jsii-kernel/test/kernel.test.ts +++ b/packages/jsii-kernel/test/kernel.test.ts @@ -32,27 +32,19 @@ if (recordingOutput) { console.error(`JSII_RECORD=${recordingOutput}`); } -function defineTest(name: string, method: (sandbox: Kernel) => Promise | any) { +function defineTest(name: string, method: (sandbox: Kernel) => Promise | any, testFunc = test) { const recording = name.replace(/[^A-Za-z]/g, '_'); - test(name, async () => { + testFunc(name, async () => { const kernel = await createCalculatorSandbox(recording); await method(kernel); - await closeRecording(kernel); + return closeRecording(kernel); }); } -defineTest('sandbox allows loading arbitrary javascript into it', (sandbox) => { - const objid = sandbox.create({ fqn: '@scope/jsii-calc-lib.Number', args: [12] }); - expect(sandbox.get({ objref: objid, property: 'doubleValue' }).value).toBe(24); - expect(sandbox.invoke({ objref: objid, method: 'typeName', args: [] }).result).toBe('Number'); - - const lhs = sandbox.create({ fqn: '@scope/jsii-calc-lib.Number', args: [10] }); - const rhs = sandbox.create({ fqn: '@scope/jsii-calc-lib.Number', args: [20] }); - const add = sandbox.create({ fqn: 'jsii-calc.Add', args: [lhs, rhs] }); - - expect(sandbox.get({ objref: add, property: 'value' }).value).toBe(30); -}); +defineTest.skip = function (name: string, method: (sandbox: Kernel) => Promise | any) { + return defineTest(name, method, test.skip); +} defineTest('stats() return sandbox statistics', (sandbox) => { const stats = sandbox.stats({ }); @@ -307,7 +299,7 @@ defineTest('verify object literals are converted to real classes', (sandbox) => expect(obj2[api.TOKEN_REF]).toBeTruthy(); // verify that we received a ref as a result; const objid: string = obj2[api.TOKEN_REF]; - expect(objid.startsWith('jsii-calc.JSObjectLiteralToNativeClass')).toBeTruthy(); // verify the type of the returned object' + expect(objid.startsWith('jsii-calc.JSObjectLiteralToNativeClass@'), `${objid} does not have the intended prefix`).toBeTruthy(); // verify the type of the returned object' }); defineTest('get a property from an type that only has base class properties', (sandbox) => { diff --git a/packages/jsii-python-runtime/src/jsii/_reference_map.py b/packages/jsii-python-runtime/src/jsii/_reference_map.py index bf04bff5b5..f4de964a6f 100644 --- a/packages/jsii-python-runtime/src/jsii/_reference_map.py +++ b/packages/jsii-python-runtime/src/jsii/_reference_map.py @@ -87,23 +87,25 @@ def resolve(self, kernel, ref): return data_type(**python_props) elif class_fqn in _enums: inst = _enums[class_fqn] - elif class_fqn in _interfaces: - # Get our proxy class by finding our interface, then asking it to give us - # the proxy class. - iface = _interfaces[class_fqn] - klass = iface.__jsii_proxy_class__() - - # Create our instance, bypassing __init__ by directly calling __new__, and - # then assign our reference to __jsii_ref__ - inst = klass.__new__(klass) - inst.__jsii_ref__ = ref elif class_fqn == "Object" and ref.interfaces is not None: - ifaces = [_interfaces[fqn] for fqn in ref.interfaces] - classes = [iface.__jsii_proxy_class__() for iface in ifaces] - insts = [klass.__new__(klass) for klass in classes] - for inst in insts: - inst.__jsii_ref__ = ref - return InterfaceDynamicProxy(insts) + if any(fqn in _data_types for fqn in ref.interfaces): + # Ugly delayed import here because I can't solve the cyclic + # package dependency right now :(. + from ._runtime import python_jsii_mapping + + structs = [_data_types[fqn] for fqn in ref.interfaces] + remote_struct = _FakeReference(ref) + insts = [struct(**{ + python_name: kernel.get(remote_struct, jsii_name) for python_name, jsii_name in python_jsii_mapping(struct).items() + }) for struct in structs] + return StructDynamicProxy(insts) + else: + ifaces = [_interfaces[fqn] for fqn in ref.interfaces] + classes = [iface.__jsii_proxy_class__() for iface in ifaces] + insts = [klass.__new__(klass) for klass in classes] + for inst in insts: + inst.__jsii_ref__ = ref + return InterfaceDynamicProxy(insts) else: raise ValueError(f"Unknown type: {class_fqn}") @@ -125,6 +127,35 @@ def __getattr__(self, name): pass return None + +class StructDynamicProxy(object): + def __init__(self, delegates): + self._delegates = delegates + + def __getattr__(self, name): + for delegate in self._delegates: + try: + return getattr(delegate, name) + except NameError: + pass + return None + + def __eq__(self, rhs) -> bool: + if len(self._delegates) == 1: + return rhs == self._delegates[0] + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs) -> bool: + return not (rhs == self) + + def __repr__(self) -> str: + if len(self._delegates) == 1: + return self._delegates[0].__repr__() + return '%s(%s)' % ( + ' & '.join([delegate.__class__.__jsii_type__ for delegate in self._delegates]), + ', '.join(k + '=' + repr(v) for k, v in self._values.items()) + ) + _refs = _ReferenceMap(_types) From 0a55a286401a5973a02e346316dacb3bf60a2c4e Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 5 Nov 2019 10:49:07 +0100 Subject: [PATCH 2/8] Add Python compliance test for calling methods on interface objects passed to callbacks In addition, fix a bug where Python's static invoke did not handle Callback results. --- packages/jsii-calc/lib/compliance.ts | 70 ++++++ packages/jsii-calc/test/assembly.jsii | 203 +++++++++++++++++- .../src/jsii/_kernel/__init__.py | 8 +- .../tests/test_compliance.py | 21 ++ .../test/__snapshots__/jsii-tree.test.js.snap | 68 ++++++ .../__snapshots__/type-system.test.js.snap | 2 + 6 files changed, 369 insertions(+), 3 deletions(-) diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index 0532bf2ab5..1bf416d879 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -2017,3 +2017,73 @@ export class StructUnionConsumer { private constructor() { } } + + +/** + * Test calling back to consumers that implement interfaces + * + * Check that if a JSII consumer implements IConsumerWithInterfaceParam, they can call + * the method on the argument that they're passed... + */ +export class ConsumerCanRingBell { + /** + * ...if the interface is implemented using an object literal. + * + * Returns whether the bell was rung. + */ + public static implementedByObjectLiteral(ringer: IBellRinger) { + let rung = false; + ringer.yourTurn({ + ring() { + rung = true; + } + }); + return rung; + } + + /** + * ...if the interface is implemented using a public class. + * + * Return whether the bell was rung. + */ + public static implementedByPublicClass(ringer: IBellRinger) { + const bell = new Bell(); + ringer.yourTurn(bell); + return bell.rung; + } + + /** + * ...if the interface is implemented using a private class. + * + * Return whether the bell was rung. + */ + public static implementedByPrivateClass(ringer: IBellRinger) { + const bell = new PrivateBell(); + ringer.yourTurn(bell); + return bell.rung; + } +} + +export interface IBellRinger { + yourTurn(bell: IBell): void; +} + +export interface IBell { + ring(): void; +} + +export class Bell implements IBell { + public rung = false; + + public ring() { + this.rung = true; + } +} + +class PrivateBell implements IBell { + public rung = false; + + public ring() { + this.rung = true; + } +} \ No newline at end of file diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 7409ef0b28..d4bbef1e2f 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -1236,6 +1236,51 @@ ], "name": "AugmentableClass" }, + "jsii-calc.Bell": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.Bell", + "initializer": {}, + "interfaces": [ + "jsii-calc.IBell" + ], + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2075 + }, + "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2078 + }, + "name": "ring", + "overrides": "jsii-calc.IBell" + } + ], + "name": "Bell", + "properties": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2076 + }, + "name": "rung", + "type": { + "primitive": "boolean" + } + } + ] + }, "jsii-calc.BinaryOperation": { "abstract": true, "assembly": "jsii-calc", @@ -2295,6 +2340,102 @@ ], "name": "Constructors" }, + "jsii-calc.ConsumerCanRingBell": { + "assembly": "jsii-calc", + "docs": { + "remarks": "Check that if a JSII consumer implements IConsumerWithInterfaceParam, they can call\nthe method on the argument that they're passed...", + "stability": "experimental", + "summary": "Test calling back to consumers that implement interfaces." + }, + "fqn": "jsii-calc.ConsumerCanRingBell", + "initializer": {}, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2028 + }, + "methods": [ + { + "docs": { + "remarks": "Returns whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using an object literal." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2034 + }, + "name": "implementedByObjectLiteral", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using a private class." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2060 + }, + "name": "implementedByPrivateClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using a public class." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2049 + }, + "name": "implementedByPublicClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true + } + ], + "name": "ConsumerCanRingBell" + }, "jsii-calc.ConsumersOfThisCrazyTypeSystem": { "assembly": "jsii-calc", "docs": { @@ -3976,6 +4117,66 @@ } ] }, + "jsii-calc.IBell": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.IBell", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2071 + }, + "methods": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2072 + }, + "name": "ring" + } + ], + "name": "IBell" + }, + "jsii-calc.IBellRinger": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.IBellRinger", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2067 + }, + "methods": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2068 + }, + "name": "yourTurn", + "parameters": [ + { + "name": "bell", + "type": { + "fqn": "jsii-calc.IBell" + } + } + ] + } + ], + "name": "IBellRinger" + }, "jsii-calc.IDeprecatedInterface": { "assembly": "jsii-calc", "docs": { @@ -10328,5 +10529,5 @@ } }, "version": "0.20.0", - "fingerprint": "Gk2mbYSx8tmjrVf/JBPBkNEFEEG9i7jx9ptKC/0sCpE=" + "fingerprint": "az8b4w4bMsALYwIzZzUorIB+wmS/IRleGIiPGXuL7hE=" } diff --git a/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py b/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py index abab0653af..bdc1dc42b3 100644 --- a/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py +++ b/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py @@ -292,13 +292,17 @@ def sinvoke( if args is None: args = [] - return self.provider.sinvoke( + response = self.provider.sinvoke( StaticInvokeRequest( fqn=klass.__jsii_type__, method=method, args=_make_reference_for_native(self, args), ) - ).result + ) + if isinstance(response, Callback): + return _callback_till_result(self, response, InvokeResponse) + else: + return response.result @_dereferenced def complete( diff --git a/packages/jsii-python-runtime/tests/test_compliance.py b/packages/jsii-python-runtime/tests/test_compliance.py index 636f3f6fdb..a1002e8649 100644 --- a/packages/jsii-python-runtime/tests/test_compliance.py +++ b/packages/jsii-python-runtime/tests/test_compliance.py @@ -14,11 +14,13 @@ AsyncVirtualMethods, Calculator, ClassWithPrivateConstructorAndAutomaticProperties, + ConsumerCanRingBell, ConstructorPassesThisOut, DataRenderer, DoNotOverridePrivates, DoubleTrouble, GreetingAugmenter, + IBellRinger, IFriendlier, IFriendlyRandomGenerator, IRandomNumberGenerator, @@ -972,3 +974,22 @@ def test_correctly_handling_struct_unions(): assert not StructUnionConsumer.is_struct_b(a1) assert StructUnionConsumer.is_struct_b(b0) assert StructUnionConsumer.is_struct_b(b1) + +def test_consumer_calls_method_objliteral(): + assert ConsumerCanRingBell.implemented_by_object_literal(PythonBellRinger()) + +def test_consumer_calls_method_publicclass(): + assert ConsumerCanRingBell.implemented_by_public_class(PythonBellRinger()) + +def test_consumer_calls_method_privateclass(): + assert ConsumerCanRingBell.implemented_by_private_class(PythonBellRinger()) + + +@jsii.implements(IBellRinger) +class PythonBellRinger: + """Python implementation of IBellRinger. + + Will ring the bell when given its turn. + """ + def your_turn(self, bell): + bell.ring() 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 d6c75e36f9..52a4713f37 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap @@ -173,6 +173,14 @@ exports[`jsii-tree --all 1`] = ` │ │ │ └── returns: void │ │ └─┬ methodTwo() method (experimental) │ │ └── returns: void + │ ├─┬ class Bell (experimental) + │ │ ├── interfaces: IBell + │ │ └─┬ members + │ │ ├── () initializer (experimental) + │ │ ├─┬ ring() method (experimental) + │ │ │ └── returns: void + │ │ └─┬ rung property (experimental) + │ │ └── type: boolean │ ├─┬ class BinaryOperation (experimental) │ │ ├── base: Operation │ │ ├── interfaces: IFriendly @@ -348,6 +356,27 @@ exports[`jsii-tree --all 1`] = ` │ │ └─┬ static makeInterfaces() method (experimental) │ │ ├── static │ │ └── returns: Array + │ ├─┬ class ConsumerCanRingBell (experimental) + │ │ └─┬ members + │ │ ├── () initializer (experimental) + │ │ ├─┬ static implementedByObjectLiteral(ringer) method (experimental) + │ │ │ ├── static + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ ringer + │ │ │ │ └── type: jsii-calc.IBellRinger + │ │ │ └── returns: boolean + │ │ ├─┬ static implementedByPrivateClass(ringer) method (experimental) + │ │ │ ├── static + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ ringer + │ │ │ │ └── type: jsii-calc.IBellRinger + │ │ │ └── returns: boolean + │ │ └─┬ static implementedByPublicClass(ringer) method (experimental) + │ │ ├── static + │ │ ├─┬ parameters + │ │ │ └─┬ ringer + │ │ │ └── type: jsii-calc.IBellRinger + │ │ └── returns: boolean │ ├─┬ class ConsumersOfThisCrazyTypeSystem (experimental) │ │ └─┬ members │ │ ├── () initializer (experimental) @@ -1569,6 +1598,19 @@ exports[`jsii-tree --all 1`] = ` │ │ └─┬ a property (experimental) │ │ ├── abstract │ │ └── type: string + │ ├─┬ interface IBell (experimental) + │ │ └─┬ members + │ │ └─┬ ring() method (experimental) + │ │ ├── abstract + │ │ └── returns: void + │ ├─┬ interface IBellRinger (experimental) + │ │ └─┬ members + │ │ └─┬ yourTurn(bell) method (experimental) + │ │ ├── abstract + │ │ ├─┬ parameters + │ │ │ └─┬ bell + │ │ │ └── type: jsii-calc.IBell + │ │ └── returns: void │ ├─┬ interface IDeprecatedInterface (deprecated) │ │ └─┬ members │ │ ├─┬ method() method (deprecated) @@ -2069,6 +2111,8 @@ exports[`jsii-tree --inheritance 1`] = ` │ │ └── interfaces: IAnonymousImplementationProvider │ ├── class AsyncVirtualMethods │ ├── class AugmentableClass + │ ├─┬ class Bell + │ │ └── interfaces: IBell │ ├─┬ class BinaryOperation │ │ ├── base: Operation │ │ └── interfaces: IFriendly @@ -2086,6 +2130,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ │ └── interfaces: IInterfaceWithProperties │ ├── class ConstructorPassesThisOut │ ├── class Constructors + │ ├── class ConsumerCanRingBell │ ├── class ConsumersOfThisCrazyTypeSystem │ ├── class DataRenderer │ ├── class DefaultedConstructorArgument @@ -2203,6 +2248,8 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├── interface IAnonymousImplementationProvider │ ├── interface IAnonymouslyImplementMe │ ├── interface IAnotherPublicInterface + │ ├── interface IBell + │ ├── interface IBellRinger │ ├── interface IDeprecatedInterface │ ├── interface IExperimentalInterface │ ├── interface IExtendsPrivateInterface @@ -2375,6 +2422,11 @@ exports[`jsii-tree --members 1`] = ` │ │ ├── () initializer │ │ ├── methodOne() method │ │ └── methodTwo() method + │ ├─┬ class Bell + │ │ └─┬ members + │ │ ├── () initializer + │ │ ├── ring() method + │ │ └── rung property │ ├─┬ class BinaryOperation │ │ └─┬ members │ │ ├── (lhs,rhs) initializer @@ -2448,6 +2500,12 @@ exports[`jsii-tree --members 1`] = ` │ │ ├── static makeInterface() method │ │ ├── static makeInterface2() method │ │ └── static makeInterfaces() method + │ ├─┬ class ConsumerCanRingBell + │ │ └─┬ members + │ │ ├── () initializer + │ │ ├── static implementedByObjectLiteral(ringer) method + │ │ ├── static implementedByPrivateClass(ringer) method + │ │ └── static implementedByPublicClass(ringer) method │ ├─┬ class ConsumersOfThisCrazyTypeSystem │ │ └─┬ members │ │ ├── () initializer @@ -2979,6 +3037,12 @@ exports[`jsii-tree --members 1`] = ` │ ├─┬ interface IAnotherPublicInterface │ │ └─┬ members │ │ └── a property + │ ├─┬ interface IBell + │ │ └─┬ members + │ │ └── ring() method + │ ├─┬ interface IBellRinger + │ │ └─┬ members + │ │ └── yourTurn(bell) method │ ├─┬ interface IDeprecatedInterface │ │ └─┬ members │ │ ├── method() method @@ -3232,6 +3296,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── class AnonymousImplementationProvider │ ├── class AsyncVirtualMethods │ ├── class AugmentableClass + │ ├── class Bell │ ├── class BinaryOperation │ ├── class Calculator │ ├── class ClassThatImplementsTheInternalInterface @@ -3243,6 +3308,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── class ClassWithPrivateConstructorAndAutomaticProperties │ ├── class ConstructorPassesThisOut │ ├── class Constructors + │ ├── class ConsumerCanRingBell │ ├── class ConsumersOfThisCrazyTypeSystem │ ├── class DataRenderer │ ├── class DefaultedConstructorArgument @@ -3333,6 +3399,8 @@ exports[`jsii-tree --types 1`] = ` │ ├── interface IAnonymousImplementationProvider │ ├── interface IAnonymouslyImplementMe │ ├── interface IAnotherPublicInterface + │ ├── interface IBell + │ ├── interface IBellRinger │ ├── interface IDeprecatedInterface │ ├── interface IExperimentalInterface │ ├── interface IExtendsPrivateInterface 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 dddc76d0ae..757aa34eca 100644 --- a/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap @@ -22,6 +22,7 @@ Array [ "AugmentableClass", "Base", "Base", + "Bell", "BinaryOperation", "Calculator", "ClassThatImplementsTheInternalInterface", @@ -34,6 +35,7 @@ Array [ "CompositeOperation", "ConstructorPassesThisOut", "Constructors", + "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", From 75c04159cb59f5c265d63d5a2ad6c1fa73e3179c Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 5 Nov 2019 12:24:25 +0100 Subject: [PATCH 3/8] Adding more tests to make sure that static and dynamic methods behave the same --- packages/jsii-calc/lib/compliance.ts | 74 +++- packages/jsii-calc/test/assembly.jsii | 80 +++- .../.jsii | 365 +++++++++++++++++- .../JSII/Tests/CalculatorNamespace/Bell.cs | 42 ++ .../ConsumerCanRingBell.cs | 114 ++++++ .../JSII/Tests/CalculatorNamespace/IBell.cs | 17 + .../Tests/CalculatorNamespace/IBellProxy.cs | 24 ++ .../Tests/CalculatorNamespace/IBellRinger.cs | 18 + .../CalculatorNamespace/IBellRingerProxy.cs | 25 ++ .../IConcreteBellRinger.cs | 18 + .../IConcreteBellRingerProxy.cs | 25 ++ .../amazon/jsii/tests/calculator/$Module.java | 5 + .../amazon/jsii/tests/calculator/Bell.java | 48 +++ .../tests/calculator/ConsumerCanRingBell.java | 140 +++++++ .../amazon/jsii/tests/calculator/IBell.java | 35 ++ .../jsii/tests/calculator/IBellRinger.java | 41 ++ .../tests/calculator/IConcreteBellRinger.java | 41 ++ .../python/src/jsii_calc/__init__.py | 268 ++++++++++++- .../tests/test_compliance.py | 29 +- .../test/__snapshots__/jsii-tree.test.js.snap | 60 ++- 20 files changed, 1441 insertions(+), 28 deletions(-) create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Bell.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ConsumerCanRingBell.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBell.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellProxy.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellRinger.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellRingerProxy.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IConcreteBellRinger.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IConcreteBellRingerProxy.cs create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Bell.java create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ConsumerCanRingBell.java create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IBell.java create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IBellRinger.java create mode 100644 packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IConcreteBellRinger.java diff --git a/packages/jsii-calc/lib/compliance.ts b/packages/jsii-calc/lib/compliance.ts index 1bf416d879..338df802af 100644 --- a/packages/jsii-calc/lib/compliance.ts +++ b/packages/jsii-calc/lib/compliance.ts @@ -2031,7 +2031,7 @@ export class ConsumerCanRingBell { * * Returns whether the bell was rung. */ - public static implementedByObjectLiteral(ringer: IBellRinger) { + public static staticImplementedByObjectLiteral(ringer: IBellRinger) { let rung = false; ringer.yourTurn({ ring() { @@ -2046,7 +2046,7 @@ export class ConsumerCanRingBell { * * Return whether the bell was rung. */ - public static implementedByPublicClass(ringer: IBellRinger) { + public static staticImplementedByPublicClass(ringer: IBellRinger) { const bell = new Bell(); ringer.yourTurn(bell); return bell.rung; @@ -2057,17 +2057,85 @@ export class ConsumerCanRingBell { * * Return whether the bell was rung. */ - public static implementedByPrivateClass(ringer: IBellRinger) { + public static staticImplementedByPrivateClass(ringer: IBellRinger) { const bell = new PrivateBell(); ringer.yourTurn(bell); return bell.rung; } + + /** + * If the parameter is a concrete class instead of an interface + * + * Return whether the bell was rung. + */ + public static staticWhenTypedAsClass(ringer: IConcreteBellRinger) { + const bell = new Bell(); + ringer.yourTurn(bell); + return bell.rung; + } + /** + * ...if the interface is implemented using an object literal. + * + * Returns whether the bell was rung. + */ + public implementedByObjectLiteral(ringer: IBellRinger) { + let rung = false; + ringer.yourTurn({ + ring() { + rung = true; + } + }); + return rung; + } + + /** + * ...if the interface is implemented using a public class. + * + * Return whether the bell was rung. + */ + public implementedByPublicClass(ringer: IBellRinger) { + const bell = new Bell(); + ringer.yourTurn(bell); + return bell.rung; + } + + /** + * ...if the interface is implemented using a private class. + * + * Return whether the bell was rung. + */ + public implementedByPrivateClass(ringer: IBellRinger) { + const bell = new PrivateBell(); + ringer.yourTurn(bell); + return bell.rung; + } + + /** + * If the parameter is a concrete class instead of an interface + * + * Return whether the bell was rung. + */ + public whenTypedAsClass(ringer: IConcreteBellRinger) { + const bell = new Bell(); + ringer.yourTurn(bell); + return bell.rung; + } } +/** + * Takes the object parameter as an interface + */ export interface IBellRinger { yourTurn(bell: IBell): void; } +/** + * Takes the object parameter as a calss + */ +export interface IConcreteBellRinger { + yourTurn(bell: Bell): void; +} + export interface IBell { ring(): void; } diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index d4bbef1e2f..84be681318 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -1249,7 +1249,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2075 + "line": 2096 }, "methods": [ { @@ -1258,7 +1258,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2078 + "line": 2099 }, "name": "ring", "overrides": "jsii-calc.IBell" @@ -1272,7 +1272,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2076 + "line": 2097 }, "name": "rung", "type": { @@ -2432,6 +2432,32 @@ } }, "static": true + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "If the parameter is a concrete class instead of an interface." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2071 + }, + "name": "whenTypedAsClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IConcreteBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true } ], "name": "ConsumerCanRingBell" @@ -4126,7 +4152,7 @@ "kind": "interface", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2071 + "line": 2092 }, "methods": [ { @@ -4136,7 +4162,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2072 + "line": 2093 }, "name": "ring" } @@ -4146,13 +4172,14 @@ "jsii-calc.IBellRinger": { "assembly": "jsii-calc", "docs": { - "stability": "experimental" + "stability": "experimental", + "summary": "Takes the object parameter as an interface." }, "fqn": "jsii-calc.IBellRinger", "kind": "interface", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2067 + "line": 2081 }, "methods": [ { @@ -4162,7 +4189,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2068 + "line": 2082 }, "name": "yourTurn", "parameters": [ @@ -4177,6 +4204,41 @@ ], "name": "IBellRinger" }, + "jsii-calc.IConcreteBellRinger": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental", + "summary": "Takes the object parameter as a calss." + }, + "fqn": "jsii-calc.IConcreteBellRinger", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2088 + }, + "methods": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2089 + }, + "name": "yourTurn", + "parameters": [ + { + "name": "bell", + "type": { + "fqn": "jsii-calc.Bell" + } + } + ] + } + ], + "name": "IConcreteBellRinger" + }, "jsii-calc.IDeprecatedInterface": { "assembly": "jsii-calc", "docs": { @@ -10529,5 +10591,5 @@ } }, "version": "0.20.0", - "fingerprint": "az8b4w4bMsALYwIzZzUorIB+wmS/IRleGIiPGXuL7hE=" + "fingerprint": "/RixCfmN1ullwcAL5vmpSlGtU7F6Aw21XykcHTYQwsY=" } 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 7409ef0b28..77dda4c784 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,51 @@ ], "name": "AugmentableClass" }, + "jsii-calc.Bell": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.Bell", + "initializer": {}, + "interfaces": [ + "jsii-calc.IBell" + ], + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2143 + }, + "methods": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2146 + }, + "name": "ring", + "overrides": "jsii-calc.IBell" + } + ], + "name": "Bell", + "properties": [ + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2144 + }, + "name": "rung", + "type": { + "primitive": "boolean" + } + } + ] + }, "jsii-calc.BinaryOperation": { "abstract": true, "assembly": "jsii-calc", @@ -2295,6 +2340,228 @@ ], "name": "Constructors" }, + "jsii-calc.ConsumerCanRingBell": { + "assembly": "jsii-calc", + "docs": { + "remarks": "Check that if a JSII consumer implements IConsumerWithInterfaceParam, they can call\nthe method on the argument that they're passed...", + "stability": "experimental", + "summary": "Test calling back to consumers that implement interfaces." + }, + "fqn": "jsii-calc.ConsumerCanRingBell", + "initializer": {}, + "kind": "class", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2028 + }, + "methods": [ + { + "docs": { + "remarks": "Returns whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using an object literal." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2034 + }, + "name": "staticImplementedByObjectLiteral", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using a private class." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2060 + }, + "name": "staticImplementedByPrivateClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using a public class." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2049 + }, + "name": "staticImplementedByPublicClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "If the parameter is a concrete class instead of an interface." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2071 + }, + "name": "staticWhenTypedAsClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IConcreteBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + }, + "static": true + }, + { + "docs": { + "remarks": "Returns whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using an object literal." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2081 + }, + "name": "implementedByObjectLiteral", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + } + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using a private class." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2107 + }, + "name": "implementedByPrivateClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + } + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using a public class." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2096 + }, + "name": "implementedByPublicClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + } + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "If the parameter is a concrete class instead of an interface." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2118 + }, + "name": "whenTypedAsClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IConcreteBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + } + } + ], + "name": "ConsumerCanRingBell" + }, "jsii-calc.ConsumersOfThisCrazyTypeSystem": { "assembly": "jsii-calc", "docs": { @@ -3976,6 +4243,102 @@ } ] }, + "jsii-calc.IBell": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.IBell", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2139 + }, + "methods": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2140 + }, + "name": "ring" + } + ], + "name": "IBell" + }, + "jsii-calc.IBellRinger": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental", + "summary": "Takes the object parameter as an interface." + }, + "fqn": "jsii-calc.IBellRinger", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2128 + }, + "methods": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2129 + }, + "name": "yourTurn", + "parameters": [ + { + "name": "bell", + "type": { + "fqn": "jsii-calc.IBell" + } + } + ] + } + ], + "name": "IBellRinger" + }, + "jsii-calc.IConcreteBellRinger": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental", + "summary": "Takes the object parameter as a calss." + }, + "fqn": "jsii-calc.IConcreteBellRinger", + "kind": "interface", + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2135 + }, + "methods": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2136 + }, + "name": "yourTurn", + "parameters": [ + { + "name": "bell", + "type": { + "fqn": "jsii-calc.Bell" + } + } + ] + } + ], + "name": "IConcreteBellRinger" + }, "jsii-calc.IDeprecatedInterface": { "assembly": "jsii-calc", "docs": { @@ -10328,5 +10691,5 @@ } }, "version": "0.20.0", - "fingerprint": "Gk2mbYSx8tmjrVf/JBPBkNEFEEG9i7jx9ptKC/0sCpE=" + "fingerprint": "0Coq8NRof9rh1e1Bpj3IE6FnQn6vS2W2at5L+Baojhg=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Bell.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Bell.cs new file mode 100644 index 0000000000..d28090559c --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Bell.cs @@ -0,0 +1,42 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// + /// stability: Experimental + /// + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Bell), fullyQualifiedName: "jsii-calc.Bell")] + public class Bell : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.IBell + { + public Bell(): base(new DeputyProps(new object[]{})) + { + } + + protected Bell(ByRefValue reference): base(reference) + { + } + + protected Bell(DeputyProps props): base(props) + { + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "ring", isOverride: true)] + public virtual void Ring() + { + InvokeInstanceVoidMethod(new System.Type[]{}, new object[]{}); + } + + /// + /// stability: Experimental + /// + [JsiiProperty(name: "rung", typeJson: "{\"primitive\":\"boolean\"}")] + public virtual bool Rung + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ConsumerCanRingBell.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ConsumerCanRingBell.cs new file mode 100644 index 0000000000..6b9579b657 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/ConsumerCanRingBell.cs @@ -0,0 +1,114 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Test calling back to consumers that implement interfaces. + /// + /// Check that if a JSII consumer implements IConsumerWithInterfaceParam, they can call + /// the method on the argument that they're passed... + /// stability: Experimental + /// + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.ConsumerCanRingBell), fullyQualifiedName: "jsii-calc.ConsumerCanRingBell")] + public class ConsumerCanRingBell : DeputyBase + { + public ConsumerCanRingBell(): base(new DeputyProps(new object[]{})) + { + } + + protected ConsumerCanRingBell(ByRefValue reference): base(reference) + { + } + + protected ConsumerCanRingBell(DeputyProps props): base(props) + { + } + + /// ...if the interface is implemented using an object literal. + /// + /// Returns whether the bell was rung. + /// stability: Experimental + /// + [JsiiMethod(name: "staticImplementedByObjectLiteral", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}", parametersJson: "[{\"name\":\"ringer\",\"type\":{\"fqn\":\"jsii-calc.IBellRinger\"}}]")] + public static bool StaticImplementedByObjectLiteral(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger ringer) + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.ConsumerCanRingBell), new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger)}, new object[]{ringer}); + } + + /// ...if the interface is implemented using a private class. + /// + /// Return whether the bell was rung. + /// stability: Experimental + /// + [JsiiMethod(name: "staticImplementedByPrivateClass", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}", parametersJson: "[{\"name\":\"ringer\",\"type\":{\"fqn\":\"jsii-calc.IBellRinger\"}}]")] + public static bool StaticImplementedByPrivateClass(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger ringer) + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.ConsumerCanRingBell), new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger)}, new object[]{ringer}); + } + + /// ...if the interface is implemented using a public class. + /// + /// Return whether the bell was rung. + /// stability: Experimental + /// + [JsiiMethod(name: "staticImplementedByPublicClass", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}", parametersJson: "[{\"name\":\"ringer\",\"type\":{\"fqn\":\"jsii-calc.IBellRinger\"}}]")] + public static bool StaticImplementedByPublicClass(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger ringer) + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.ConsumerCanRingBell), new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger)}, new object[]{ringer}); + } + + /// If the parameter is a concrete class instead of an interface. + /// + /// Return whether the bell was rung. + /// stability: Experimental + /// + [JsiiMethod(name: "staticWhenTypedAsClass", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}", parametersJson: "[{\"name\":\"ringer\",\"type\":{\"fqn\":\"jsii-calc.IConcreteBellRinger\"}}]")] + public static bool StaticWhenTypedAsClass(Amazon.JSII.Tests.CalculatorNamespace.IConcreteBellRinger ringer) + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.ConsumerCanRingBell), new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.IConcreteBellRinger)}, new object[]{ringer}); + } + + /// ...if the interface is implemented using an object literal. + /// + /// Returns whether the bell was rung. + /// stability: Experimental + /// + [JsiiMethod(name: "implementedByObjectLiteral", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}", parametersJson: "[{\"name\":\"ringer\",\"type\":{\"fqn\":\"jsii-calc.IBellRinger\"}}]")] + public virtual bool ImplementedByObjectLiteral(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger ringer) + { + return InvokeInstanceMethod(new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger)}, new object[]{ringer}); + } + + /// ...if the interface is implemented using a private class. + /// + /// Return whether the bell was rung. + /// stability: Experimental + /// + [JsiiMethod(name: "implementedByPrivateClass", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}", parametersJson: "[{\"name\":\"ringer\",\"type\":{\"fqn\":\"jsii-calc.IBellRinger\"}}]")] + public virtual bool ImplementedByPrivateClass(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger ringer) + { + return InvokeInstanceMethod(new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger)}, new object[]{ringer}); + } + + /// ...if the interface is implemented using a public class. + /// + /// Return whether the bell was rung. + /// stability: Experimental + /// + [JsiiMethod(name: "implementedByPublicClass", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}", parametersJson: "[{\"name\":\"ringer\",\"type\":{\"fqn\":\"jsii-calc.IBellRinger\"}}]")] + public virtual bool ImplementedByPublicClass(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger ringer) + { + return InvokeInstanceMethod(new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.IBellRinger)}, new object[]{ringer}); + } + + /// If the parameter is a concrete class instead of an interface. + /// + /// Return whether the bell was rung. + /// stability: Experimental + /// + [JsiiMethod(name: "whenTypedAsClass", returnsJson: "{\"type\":{\"primitive\":\"boolean\"}}", parametersJson: "[{\"name\":\"ringer\",\"type\":{\"fqn\":\"jsii-calc.IConcreteBellRinger\"}}]")] + public virtual bool WhenTypedAsClass(Amazon.JSII.Tests.CalculatorNamespace.IConcreteBellRinger ringer) + { + return InvokeInstanceMethod(new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.IConcreteBellRinger)}, new object[]{ringer}); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBell.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBell.cs new file mode 100644 index 0000000000..4918346074 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBell.cs @@ -0,0 +1,17 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// + /// stability: Experimental + /// + [JsiiInterface(nativeType: typeof(IBell), fullyQualifiedName: "jsii-calc.IBell")] + public interface IBell + { + /// + /// stability: Experimental + /// + [JsiiMethod(name: "ring")] + void Ring(); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellProxy.cs new file mode 100644 index 0000000000..e8312b476f --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellProxy.cs @@ -0,0 +1,24 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// + /// stability: Experimental + /// + [JsiiTypeProxy(nativeType: typeof(IBell), fullyQualifiedName: "jsii-calc.IBell")] + internal sealed class IBellProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.IBell + { + private IBellProxy(ByRefValue reference): base(reference) + { + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "ring")] + public void Ring() + { + InvokeInstanceVoidMethod(new System.Type[]{}, new object[]{}); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellRinger.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellRinger.cs new file mode 100644 index 0000000000..b6e89c8d48 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellRinger.cs @@ -0,0 +1,18 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Takes the object parameter as an interface. + /// + /// stability: Experimental + /// + [JsiiInterface(nativeType: typeof(IBellRinger), fullyQualifiedName: "jsii-calc.IBellRinger")] + public interface IBellRinger + { + /// + /// stability: Experimental + /// + [JsiiMethod(name: "yourTurn", parametersJson: "[{\"name\":\"bell\",\"type\":{\"fqn\":\"jsii-calc.IBell\"}}]")] + void YourTurn(Amazon.JSII.Tests.CalculatorNamespace.IBell bell); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellRingerProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellRingerProxy.cs new file mode 100644 index 0000000000..5f77328934 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IBellRingerProxy.cs @@ -0,0 +1,25 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Takes the object parameter as an interface. + /// + /// stability: Experimental + /// + [JsiiTypeProxy(nativeType: typeof(IBellRinger), fullyQualifiedName: "jsii-calc.IBellRinger")] + internal sealed class IBellRingerProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.IBellRinger + { + private IBellRingerProxy(ByRefValue reference): base(reference) + { + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "yourTurn", parametersJson: "[{\"name\":\"bell\",\"type\":{\"fqn\":\"jsii-calc.IBell\"}}]")] + public void YourTurn(Amazon.JSII.Tests.CalculatorNamespace.IBell bell) + { + InvokeInstanceVoidMethod(new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.IBell)}, new object[]{bell}); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IConcreteBellRinger.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IConcreteBellRinger.cs new file mode 100644 index 0000000000..b37908a316 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IConcreteBellRinger.cs @@ -0,0 +1,18 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Takes the object parameter as a calss. + /// + /// stability: Experimental + /// + [JsiiInterface(nativeType: typeof(IConcreteBellRinger), fullyQualifiedName: "jsii-calc.IConcreteBellRinger")] + public interface IConcreteBellRinger + { + /// + /// stability: Experimental + /// + [JsiiMethod(name: "yourTurn", parametersJson: "[{\"name\":\"bell\",\"type\":{\"fqn\":\"jsii-calc.Bell\"}}]")] + void YourTurn(Amazon.JSII.Tests.CalculatorNamespace.Bell bell); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IConcreteBellRingerProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IConcreteBellRingerProxy.cs new file mode 100644 index 0000000000..2aca594364 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IConcreteBellRingerProxy.cs @@ -0,0 +1,25 @@ +using Amazon.JSII.Runtime.Deputy; + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + /// Takes the object parameter as a calss. + /// + /// stability: Experimental + /// + [JsiiTypeProxy(nativeType: typeof(IConcreteBellRinger), fullyQualifiedName: "jsii-calc.IConcreteBellRinger")] + internal sealed class IConcreteBellRingerProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.IConcreteBellRinger + { + private IConcreteBellRingerProxy(ByRefValue reference): base(reference) + { + } + + /// + /// stability: Experimental + /// + [JsiiMethod(name: "yourTurn", parametersJson: "[{\"name\":\"bell\",\"type\":{\"fqn\":\"jsii-calc.Bell\"}}]")] + public void YourTurn(Amazon.JSII.Tests.CalculatorNamespace.Bell bell) + { + InvokeInstanceVoidMethod(new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.Bell)}, new object[]{bell}); + } + } +} 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 5cda6373de..4dd69b061c 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java @@ -28,6 +28,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.AnonymousImplementationProvider": return software.amazon.jsii.tests.calculator.AnonymousImplementationProvider.class; case "jsii-calc.AsyncVirtualMethods": return software.amazon.jsii.tests.calculator.AsyncVirtualMethods.class; case "jsii-calc.AugmentableClass": return software.amazon.jsii.tests.calculator.AugmentableClass.class; + case "jsii-calc.Bell": return software.amazon.jsii.tests.calculator.Bell.class; case "jsii-calc.BinaryOperation": return software.amazon.jsii.tests.calculator.BinaryOperation.class; case "jsii-calc.Calculator": return software.amazon.jsii.tests.calculator.Calculator.class; case "jsii-calc.CalculatorProps": return software.amazon.jsii.tests.calculator.CalculatorProps.class; @@ -40,6 +41,7 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.ClassWithPrivateConstructorAndAutomaticProperties": return software.amazon.jsii.tests.calculator.ClassWithPrivateConstructorAndAutomaticProperties.class; case "jsii-calc.ConstructorPassesThisOut": return software.amazon.jsii.tests.calculator.ConstructorPassesThisOut.class; case "jsii-calc.Constructors": return software.amazon.jsii.tests.calculator.Constructors.class; + case "jsii-calc.ConsumerCanRingBell": return software.amazon.jsii.tests.calculator.ConsumerCanRingBell.class; case "jsii-calc.ConsumersOfThisCrazyTypeSystem": return software.amazon.jsii.tests.calculator.ConsumersOfThisCrazyTypeSystem.class; case "jsii-calc.DataRenderer": return software.amazon.jsii.tests.calculator.DataRenderer.class; case "jsii-calc.DefaultedConstructorArgument": return software.amazon.jsii.tests.calculator.DefaultedConstructorArgument.class; @@ -72,6 +74,9 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.IAnonymousImplementationProvider": return software.amazon.jsii.tests.calculator.IAnonymousImplementationProvider.class; case "jsii-calc.IAnonymouslyImplementMe": return software.amazon.jsii.tests.calculator.IAnonymouslyImplementMe.class; case "jsii-calc.IAnotherPublicInterface": return software.amazon.jsii.tests.calculator.IAnotherPublicInterface.class; + case "jsii-calc.IBell": return software.amazon.jsii.tests.calculator.IBell.class; + case "jsii-calc.IBellRinger": return software.amazon.jsii.tests.calculator.IBellRinger.class; + case "jsii-calc.IConcreteBellRinger": return software.amazon.jsii.tests.calculator.IConcreteBellRinger.class; case "jsii-calc.IDeprecatedInterface": return software.amazon.jsii.tests.calculator.IDeprecatedInterface.class; case "jsii-calc.IExperimentalInterface": return software.amazon.jsii.tests.calculator.IExperimentalInterface.class; case "jsii-calc.IExtendsPrivateInterface": return software.amazon.jsii.tests.calculator.IExtendsPrivateInterface.class; diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Bell.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Bell.java new file mode 100644 index 0000000000..fd4013bc67 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/Bell.java @@ -0,0 +1,48 @@ +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.Bell") +public class Bell extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IBell { + + protected Bell(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected Bell(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + public Bell() { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + @Override + public void ring() { + this.jsiiCall("ring", Void.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public java.lang.Boolean getRung() { + return this.jsiiGet("rung", java.lang.Boolean.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public void setRung(final java.lang.Boolean value) { + this.jsiiSet("rung", java.util.Objects.requireNonNull(value, "rung is required")); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ConsumerCanRingBell.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ConsumerCanRingBell.java new file mode 100644 index 0000000000..1397c79d1d --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/ConsumerCanRingBell.java @@ -0,0 +1,140 @@ +package software.amazon.jsii.tests.calculator; + +/** + * Test calling back to consumers that implement interfaces. + * + * Check that if a JSII consumer implements IConsumerWithInterfaceParam, they can call + * the method on the argument that they're passed... + * + * 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.ConsumerCanRingBell") +public class ConsumerCanRingBell extends software.amazon.jsii.JsiiObject { + + protected ConsumerCanRingBell(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected ConsumerCanRingBell(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + public ConsumerCanRingBell() { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + /** + * ...if the interface is implemented using an object literal. + * + * Returns whether the bell was rung. + * + * EXPERIMENTAL + * + * @param ringer This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Boolean staticImplementedByObjectLiteral(final software.amazon.jsii.tests.calculator.IBellRinger ringer) { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.ConsumerCanRingBell.class, "staticImplementedByObjectLiteral", java.lang.Boolean.class, new Object[] { java.util.Objects.requireNonNull(ringer, "ringer is required") }); + } + + /** + * ...if the interface is implemented using a private class. + * + * Return whether the bell was rung. + * + * EXPERIMENTAL + * + * @param ringer This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Boolean staticImplementedByPrivateClass(final software.amazon.jsii.tests.calculator.IBellRinger ringer) { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.ConsumerCanRingBell.class, "staticImplementedByPrivateClass", java.lang.Boolean.class, new Object[] { java.util.Objects.requireNonNull(ringer, "ringer is required") }); + } + + /** + * ...if the interface is implemented using a public class. + * + * Return whether the bell was rung. + * + * EXPERIMENTAL + * + * @param ringer This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Boolean staticImplementedByPublicClass(final software.amazon.jsii.tests.calculator.IBellRinger ringer) { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.ConsumerCanRingBell.class, "staticImplementedByPublicClass", java.lang.Boolean.class, new Object[] { java.util.Objects.requireNonNull(ringer, "ringer is required") }); + } + + /** + * If the parameter is a concrete class instead of an interface. + * + * Return whether the bell was rung. + * + * EXPERIMENTAL + * + * @param ringer This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static java.lang.Boolean staticWhenTypedAsClass(final software.amazon.jsii.tests.calculator.IConcreteBellRinger ringer) { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.ConsumerCanRingBell.class, "staticWhenTypedAsClass", java.lang.Boolean.class, new Object[] { java.util.Objects.requireNonNull(ringer, "ringer is required") }); + } + + /** + * ...if the interface is implemented using an object literal. + * + * Returns whether the bell was rung. + * + * EXPERIMENTAL + * + * @param ringer This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public java.lang.Boolean implementedByObjectLiteral(final software.amazon.jsii.tests.calculator.IBellRinger ringer) { + return this.jsiiCall("implementedByObjectLiteral", java.lang.Boolean.class, new Object[] { java.util.Objects.requireNonNull(ringer, "ringer is required") }); + } + + /** + * ...if the interface is implemented using a private class. + * + * Return whether the bell was rung. + * + * EXPERIMENTAL + * + * @param ringer This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public java.lang.Boolean implementedByPrivateClass(final software.amazon.jsii.tests.calculator.IBellRinger ringer) { + return this.jsiiCall("implementedByPrivateClass", java.lang.Boolean.class, new Object[] { java.util.Objects.requireNonNull(ringer, "ringer is required") }); + } + + /** + * ...if the interface is implemented using a public class. + * + * Return whether the bell was rung. + * + * EXPERIMENTAL + * + * @param ringer This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public java.lang.Boolean implementedByPublicClass(final software.amazon.jsii.tests.calculator.IBellRinger ringer) { + return this.jsiiCall("implementedByPublicClass", java.lang.Boolean.class, new Object[] { java.util.Objects.requireNonNull(ringer, "ringer is required") }); + } + + /** + * If the parameter is a concrete class instead of an interface. + * + * Return whether the bell was rung. + * + * EXPERIMENTAL + * + * @param ringer This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public java.lang.Boolean whenTypedAsClass(final software.amazon.jsii.tests.calculator.IConcreteBellRinger ringer) { + return this.jsiiCall("whenTypedAsClass", java.lang.Boolean.class, new Object[] { java.util.Objects.requireNonNull(ringer, "ringer is required") }); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IBell.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IBell.java new file mode 100644 index 0000000000..99a9496d0e --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IBell.java @@ -0,0 +1,35 @@ +package software.amazon.jsii.tests.calculator; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.IBell") +@software.amazon.jsii.Jsii.Proxy(IBell.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +public interface IBell extends software.amazon.jsii.JsiiSerializable { + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + void ring(); + + /** + * A proxy class which represents a concrete javascript instance of this type. + */ + final static class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IBell { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + @Override + public void ring() { + this.jsiiCall("ring", Void.class); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IBellRinger.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IBellRinger.java new file mode 100644 index 0000000000..c4766a56b0 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IBellRinger.java @@ -0,0 +1,41 @@ +package software.amazon.jsii.tests.calculator; + +/** + * Takes the object parameter as an interface. + * + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.IBellRinger") +@software.amazon.jsii.Jsii.Proxy(IBellRinger.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +public interface IBellRinger extends software.amazon.jsii.JsiiSerializable { + + /** + * EXPERIMENTAL + * + * @param bell This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + void yourTurn(final software.amazon.jsii.tests.calculator.IBell bell); + + /** + * A proxy class which represents a concrete javascript instance of this type. + */ + final static class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IBellRinger { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + /** + * EXPERIMENTAL + * + * @param bell This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + @Override + public void yourTurn(final software.amazon.jsii.tests.calculator.IBell bell) { + this.jsiiCall("yourTurn", Void.class, new Object[] { java.util.Objects.requireNonNull(bell, "bell is required") }); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IConcreteBellRinger.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IConcreteBellRinger.java new file mode 100644 index 0000000000..6399871e19 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/IConcreteBellRinger.java @@ -0,0 +1,41 @@ +package software.amazon.jsii.tests.calculator; + +/** + * Takes the object parameter as a calss. + * + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.IConcreteBellRinger") +@software.amazon.jsii.Jsii.Proxy(IConcreteBellRinger.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +public interface IConcreteBellRinger extends software.amazon.jsii.JsiiSerializable { + + /** + * EXPERIMENTAL + * + * @param bell This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + void yourTurn(final software.amazon.jsii.tests.calculator.Bell bell); + + /** + * A proxy class which represents a concrete javascript instance of this type. + */ + final static class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.IConcreteBellRinger { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + /** + * EXPERIMENTAL + * + * @param bell This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + @Override + public void yourTurn(final software.amazon.jsii.tests.calculator.Bell bell) { + this.jsiiCall("yourTurn", Void.class, new Object[] { java.util.Objects.requireNonNull(bell, "bell is required") }); + } + } +} 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 d82a907203..879ac579fa 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 @@ -935,6 +935,127 @@ def make_interfaces(cls) -> typing.List["IPublicInterface"]: return jsii.sinvoke(cls, "makeInterfaces", []) +class ConsumerCanRingBell(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ConsumerCanRingBell"): + """Test calling back to consumers that implement interfaces. + + Check that if a JSII consumer implements IConsumerWithInterfaceParam, they can call + the method on the argument that they're passed... + + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(ConsumerCanRingBell, self, []) + + @jsii.member(jsii_name="staticImplementedByObjectLiteral") + @classmethod + def static_implemented_by_object_literal(cls, ringer: "IBellRinger") -> bool: + """...if the interface is implemented using an object literal. + + Returns whether the bell was rung. + + :param ringer: - + + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "staticImplementedByObjectLiteral", [ringer]) + + @jsii.member(jsii_name="staticImplementedByPrivateClass") + @classmethod + def static_implemented_by_private_class(cls, ringer: "IBellRinger") -> bool: + """...if the interface is implemented using a private class. + + Return whether the bell was rung. + + :param ringer: - + + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "staticImplementedByPrivateClass", [ringer]) + + @jsii.member(jsii_name="staticImplementedByPublicClass") + @classmethod + def static_implemented_by_public_class(cls, ringer: "IBellRinger") -> bool: + """...if the interface is implemented using a public class. + + Return whether the bell was rung. + + :param ringer: - + + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "staticImplementedByPublicClass", [ringer]) + + @jsii.member(jsii_name="staticWhenTypedAsClass") + @classmethod + def static_when_typed_as_class(cls, ringer: "IConcreteBellRinger") -> bool: + """If the parameter is a concrete class instead of an interface. + + Return whether the bell was rung. + + :param ringer: - + + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "staticWhenTypedAsClass", [ringer]) + + @jsii.member(jsii_name="implementedByObjectLiteral") + def implemented_by_object_literal(self, ringer: "IBellRinger") -> bool: + """...if the interface is implemented using an object literal. + + Returns whether the bell was rung. + + :param ringer: - + + stability + :stability: experimental + """ + return jsii.invoke(self, "implementedByObjectLiteral", [ringer]) + + @jsii.member(jsii_name="implementedByPrivateClass") + def implemented_by_private_class(self, ringer: "IBellRinger") -> bool: + """...if the interface is implemented using a private class. + + Return whether the bell was rung. + + :param ringer: - + + stability + :stability: experimental + """ + return jsii.invoke(self, "implementedByPrivateClass", [ringer]) + + @jsii.member(jsii_name="implementedByPublicClass") + def implemented_by_public_class(self, ringer: "IBellRinger") -> bool: + """...if the interface is implemented using a public class. + + Return whether the bell was rung. + + :param ringer: - + + stability + :stability: experimental + """ + return jsii.invoke(self, "implementedByPublicClass", [ringer]) + + @jsii.member(jsii_name="whenTypedAsClass") + def when_typed_as_class(self, ringer: "IConcreteBellRinger") -> bool: + """If the parameter is a concrete class instead of an interface. + + Return whether the bell was rung. + + :param ringer: - + + stability + :stability: experimental + """ + return jsii.invoke(self, "whenTypedAsClass", [ringer]) + + class ConsumersOfThisCrazyTypeSystem(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ConsumersOfThisCrazyTypeSystem"): """ stability @@ -2195,6 +2316,151 @@ def a(self, value: str): return jsii.set(self, "a", value) +@jsii.interface(jsii_type="jsii-calc.IBell") +class IBell(jsii.compat.Protocol): + """ + stability + :stability: experimental + """ + @staticmethod + def __jsii_proxy_class__(): + return _IBellProxy + + @jsii.member(jsii_name="ring") + def ring(self) -> None: + """ + stability + :stability: experimental + """ + ... + + +class _IBellProxy(): + """ + stability + :stability: experimental + """ + __jsii_type__ = "jsii-calc.IBell" + @jsii.member(jsii_name="ring") + def ring(self) -> None: + """ + stability + :stability: experimental + """ + return jsii.invoke(self, "ring", []) + + +@jsii.implements(IBell) +class Bell(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Bell"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(Bell, self, []) + + @jsii.member(jsii_name="ring") + def ring(self) -> None: + """ + stability + :stability: experimental + """ + return jsii.invoke(self, "ring", []) + + @property + @jsii.member(jsii_name="rung") + def rung(self) -> bool: + """ + stability + :stability: experimental + """ + return jsii.get(self, "rung") + + @rung.setter + def rung(self, value: bool): + return jsii.set(self, "rung", value) + + +@jsii.interface(jsii_type="jsii-calc.IBellRinger") +class IBellRinger(jsii.compat.Protocol): + """Takes the object parameter as an interface. + + stability + :stability: experimental + """ + @staticmethod + def __jsii_proxy_class__(): + return _IBellRingerProxy + + @jsii.member(jsii_name="yourTurn") + def your_turn(self, bell: "IBell") -> None: + """ + :param bell: - + + stability + :stability: experimental + """ + ... + + +class _IBellRingerProxy(): + """Takes the object parameter as an interface. + + stability + :stability: experimental + """ + __jsii_type__ = "jsii-calc.IBellRinger" + @jsii.member(jsii_name="yourTurn") + def your_turn(self, bell: "IBell") -> None: + """ + :param bell: - + + stability + :stability: experimental + """ + return jsii.invoke(self, "yourTurn", [bell]) + + +@jsii.interface(jsii_type="jsii-calc.IConcreteBellRinger") +class IConcreteBellRinger(jsii.compat.Protocol): + """Takes the object parameter as a calss. + + stability + :stability: experimental + """ + @staticmethod + def __jsii_proxy_class__(): + return _IConcreteBellRingerProxy + + @jsii.member(jsii_name="yourTurn") + def your_turn(self, bell: "Bell") -> None: + """ + :param bell: - + + stability + :stability: experimental + """ + ... + + +class _IConcreteBellRingerProxy(): + """Takes the object parameter as a calss. + + stability + :stability: experimental + """ + __jsii_type__ = "jsii-calc.IConcreteBellRinger" + @jsii.member(jsii_name="yourTurn") + def your_turn(self, bell: "Bell") -> None: + """ + :param bell: - + + stability + :stability: experimental + """ + return jsii.invoke(self, "yourTurn", [bell]) + + @jsii.interface(jsii_type="jsii-calc.IDeprecatedInterface") class IDeprecatedInterface(jsii.compat.Protocol): """ @@ -7236,6 +7502,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", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "IStableInterface", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] +__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass", "Bell", "BinaryOperation", "Calculator", "CalculatorProps", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConstructorPassesThisOut", "Constructors", "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IBell", "IBellRinger", "IConcreteBellRinger", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnsNumber", "IStableInterface", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "LoadBalancedFargateServiceProps", "Multiply", "Negate", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "Old", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] publication.publish() diff --git a/packages/jsii-python-runtime/tests/test_compliance.py b/packages/jsii-python-runtime/tests/test_compliance.py index a1002e8649..8a36fa3cbf 100644 --- a/packages/jsii-python-runtime/tests/test_compliance.py +++ b/packages/jsii-python-runtime/tests/test_compliance.py @@ -21,6 +21,7 @@ DoubleTrouble, GreetingAugmenter, IBellRinger, + IConcreteBellRinger, IFriendlier, IFriendlyRandomGenerator, IRandomNumberGenerator, @@ -975,21 +976,37 @@ def test_correctly_handling_struct_unions(): assert StructUnionConsumer.is_struct_b(b0) assert StructUnionConsumer.is_struct_b(b1) +def test_consumer_calls_method_static_objliteral(): + assert ConsumerCanRingBell.static_implemented_by_object_literal(PythonBellRinger()) + +def test_consumer_calls_method_static_publicclass(): + assert ConsumerCanRingBell.static_implemented_by_public_class(PythonBellRinger()) + +def test_consumer_calls_method_static_privateclass(): + assert ConsumerCanRingBell.static_implemented_by_private_class(PythonBellRinger()) + +def test_consumer_calls_method_static_typed_as_class(): + assert ConsumerCanRingBell.static_when_typed_as_class(PythonConcreteBellRinger()) + def test_consumer_calls_method_objliteral(): - assert ConsumerCanRingBell.implemented_by_object_literal(PythonBellRinger()) + assert ConsumerCanRingBell().implemented_by_object_literal(PythonBellRinger()) def test_consumer_calls_method_publicclass(): - assert ConsumerCanRingBell.implemented_by_public_class(PythonBellRinger()) + assert ConsumerCanRingBell().implemented_by_public_class(PythonBellRinger()) def test_consumer_calls_method_privateclass(): - assert ConsumerCanRingBell.implemented_by_private_class(PythonBellRinger()) + assert ConsumerCanRingBell().implemented_by_private_class(PythonBellRinger()) + +def test_consumer_calls_method_typed_as_class(): + assert ConsumerCanRingBell().when_typed_as_class(PythonConcreteBellRinger()) @jsii.implements(IBellRinger) class PythonBellRinger: - """Python implementation of IBellRinger. + def your_turn(self, bell): + bell.ring() - Will ring the bell when given its turn. - """ +@jsii.implements(IConcreteBellRinger) +class PythonConcreteBellRinger: def your_turn(self, bell): bell.ring() 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 52a4713f37..6e5e2f0885 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap @@ -359,23 +359,49 @@ exports[`jsii-tree --all 1`] = ` │ ├─┬ class ConsumerCanRingBell (experimental) │ │ └─┬ members │ │ ├── () initializer (experimental) - │ │ ├─┬ static implementedByObjectLiteral(ringer) method (experimental) + │ │ ├─┬ static staticImplementedByObjectLiteral(ringer) method (experimental) │ │ │ ├── static │ │ │ ├─┬ parameters │ │ │ │ └─┬ ringer │ │ │ │ └── type: jsii-calc.IBellRinger │ │ │ └── returns: boolean - │ │ ├─┬ static implementedByPrivateClass(ringer) method (experimental) + │ │ ├─┬ static staticImplementedByPrivateClass(ringer) method (experimental) │ │ │ ├── static │ │ │ ├─┬ parameters │ │ │ │ └─┬ ringer │ │ │ │ └── type: jsii-calc.IBellRinger │ │ │ └── returns: boolean - │ │ └─┬ static implementedByPublicClass(ringer) method (experimental) - │ │ ├── static + │ │ ├─┬ static staticImplementedByPublicClass(ringer) method (experimental) + │ │ │ ├── static + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ ringer + │ │ │ │ └── type: jsii-calc.IBellRinger + │ │ │ └── returns: boolean + │ │ ├─┬ static staticWhenTypedAsClass(ringer) method (experimental) + │ │ │ ├── static + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ ringer + │ │ │ │ └── type: jsii-calc.IConcreteBellRinger + │ │ │ └── returns: boolean + │ │ ├─┬ implementedByObjectLiteral(ringer) method (experimental) + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ ringer + │ │ │ │ └── type: jsii-calc.IBellRinger + │ │ │ └── returns: boolean + │ │ ├─┬ implementedByPrivateClass(ringer) method (experimental) + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ ringer + │ │ │ │ └── type: jsii-calc.IBellRinger + │ │ │ └── returns: boolean + │ │ ├─┬ implementedByPublicClass(ringer) method (experimental) + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ ringer + │ │ │ │ └── type: jsii-calc.IBellRinger + │ │ │ └── returns: boolean + │ │ └─┬ whenTypedAsClass(ringer) method (experimental) │ │ ├─┬ parameters │ │ │ └─┬ ringer - │ │ │ └── type: jsii-calc.IBellRinger + │ │ │ └── type: jsii-calc.IConcreteBellRinger │ │ └── returns: boolean │ ├─┬ class ConsumersOfThisCrazyTypeSystem (experimental) │ │ └─┬ members @@ -1611,6 +1637,14 @@ exports[`jsii-tree --all 1`] = ` │ │ │ └─┬ bell │ │ │ └── type: jsii-calc.IBell │ │ └── returns: void + │ ├─┬ interface IConcreteBellRinger (experimental) + │ │ └─┬ members + │ │ └─┬ yourTurn(bell) method (experimental) + │ │ ├── abstract + │ │ ├─┬ parameters + │ │ │ └─┬ bell + │ │ │ └── type: jsii-calc.Bell + │ │ └── returns: void │ ├─┬ interface IDeprecatedInterface (deprecated) │ │ └─┬ members │ │ ├─┬ method() method (deprecated) @@ -2250,6 +2284,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├── interface IAnotherPublicInterface │ ├── interface IBell │ ├── interface IBellRinger + │ ├── interface IConcreteBellRinger │ ├── interface IDeprecatedInterface │ ├── interface IExperimentalInterface │ ├── interface IExtendsPrivateInterface @@ -2503,9 +2538,14 @@ exports[`jsii-tree --members 1`] = ` │ ├─┬ class ConsumerCanRingBell │ │ └─┬ members │ │ ├── () initializer - │ │ ├── static implementedByObjectLiteral(ringer) method - │ │ ├── static implementedByPrivateClass(ringer) method - │ │ └── static implementedByPublicClass(ringer) method + │ │ ├── static staticImplementedByObjectLiteral(ringer) method + │ │ ├── static staticImplementedByPrivateClass(ringer) method + │ │ ├── static staticImplementedByPublicClass(ringer) method + │ │ ├── static staticWhenTypedAsClass(ringer) method + │ │ ├── implementedByObjectLiteral(ringer) method + │ │ ├── implementedByPrivateClass(ringer) method + │ │ ├── implementedByPublicClass(ringer) method + │ │ └── whenTypedAsClass(ringer) method │ ├─┬ class ConsumersOfThisCrazyTypeSystem │ │ └─┬ members │ │ ├── () initializer @@ -3043,6 +3083,9 @@ exports[`jsii-tree --members 1`] = ` │ ├─┬ interface IBellRinger │ │ └─┬ members │ │ └── yourTurn(bell) method + │ ├─┬ interface IConcreteBellRinger + │ │ └─┬ members + │ │ └── yourTurn(bell) method │ ├─┬ interface IDeprecatedInterface │ │ └─┬ members │ │ ├── method() method @@ -3401,6 +3444,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── interface IAnotherPublicInterface │ ├── interface IBell │ ├── interface IBellRinger + │ ├── interface IConcreteBellRinger │ ├── interface IDeprecatedInterface │ ├── interface IExperimentalInterface │ ├── interface IExtendsPrivateInterface From 9acdfb81da3674b6ae7fa1652909ee1a82b7916d Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 5 Nov 2019 13:02:10 +0100 Subject: [PATCH 4/8] Add missing hydration step when handling callbacks This fixes callback object deserialization for publicly exposed classes. --- packages/jsii-python-runtime/src/jsii/_kernel/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py b/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py index bdc1dc42b3..22fdb93516 100644 --- a/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py +++ b/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py @@ -151,13 +151,15 @@ def _handle_callback(kernel, callback): if callback.invoke: obj = _reference_map.resolve_id(callback.invoke.objref.ref) method = getattr(obj, callback.cookie) - return method(*callback.invoke.args) + hydrated_args = [_recursize_dereference(kernel, a) for a in callback.invoke.args] + return method(*hydrated_args) elif callback.get: obj = _reference_map.resolve_id(callback.get.objref.ref) return getattr(obj, callback.cookie) elif callback.set: obj = _reference_map.resolve_id(callback.set.objref.ref) - return setattr(obj, callback.cookie, callback.set.value) + hydrated_value = _recursize_dereference(kernel, callback.set.value) + return setattr(obj, callback.cookie, hydrated_value) else: raise JSIIError("Callback does not contain invoke|get|set") From 6177c537550d38ec836348becfb0a08fc62b019e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Tue, 5 Nov 2019 13:16:11 +0100 Subject: [PATCH 5/8] some python runtime fixes --- .../src/jsii/_kernel/__init__.py | 16 +++++++++++----- .../src/jsii/_kernel/types.py | 5 +++++ .../jsii-python-runtime/src/jsii/_runtime.py | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py b/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py index 22fdb93516..438598544d 100644 --- a/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py +++ b/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py @@ -63,7 +63,9 @@ def _get_overides(klass: JSClass, obj: Any) -> List[Override]: ) ) for mro_klass in type(obj).mro(): - if mro_klass is klass: + if mro_klass is klass and getattr(mro_klass, "__jsii_type__", "Object") is not None: + break + if mro_klass is Object: break for name, item in mro_klass.__dict__.items(): @@ -119,7 +121,7 @@ def _make_reference_for_native(kernel, d): elif isinstance(d, list): return [_make_reference_for_native(kernel, i) for i in d] - if hasattr(d, "__jsii_type__"): + if getattr(d, "__jsii_type__", None) is not None: typeFqn = getattr(d, "__jsii_type__") mapping = python_jsii_mapping(d) if mapping: # This means we are handling a data_type (aka Struct) @@ -140,8 +142,7 @@ def _make_reference_for_native(kernel, d): # but we still want to serialize them as normal. raise JSIIError("Cannot pass function as argument here (did you mean to call this function?): %r" % d) else: - d.__jsii__type__ = "Object" - kernel.create(Object, d) + kernel.create(d.__class__, d) _reference_map.register_reference(d) return d @@ -216,11 +217,16 @@ def create( overrides = _get_overides(klass, obj) + interfaces = None + if klass.__jsii_ifaces__ is not None: + interfaces = [iface.__jsii_type__ for iface in klass.__jsii_ifaces__] + response = self.provider.create( CreateRequest( - fqn=klass.__jsii_type__, + fqn=klass.__jsii_type__ or "Object", args=_make_reference_for_native(self, args), overrides=overrides, + interfaces=interfaces, ) ) if isinstance(response, Callback): diff --git a/packages/jsii-python-runtime/src/jsii/_kernel/types.py b/packages/jsii-python-runtime/src/jsii/_kernel/types.py index 93f159134f..60ea15e248 100644 --- a/packages/jsii-python-runtime/src/jsii/_kernel/types.py +++ b/packages/jsii-python-runtime/src/jsii/_kernel/types.py @@ -54,6 +54,7 @@ class CreateRequest: fqn: str args: List[Any] = attr.Factory(list) overrides: List[Override] = attr.Factory(list) + interfaces: Optional[List[str]] = attr.Factory(Optional[list]) @attr.s(auto_attribs=True, frozen=True, slots=True) @@ -248,6 +249,10 @@ def __jsii_type__(self) -> str: Returns a str that points to this class inside of the Javascript runtime. """ + def __jsii_ifaces__(self) -> Optional[List['JSClass']]: + """ + Returns an Optional[List['JSClass']] that represents interfaces implemented by this class (if any). + """ class Referenceable(Protocol): @property diff --git a/packages/jsii-python-runtime/src/jsii/_runtime.py b/packages/jsii-python-runtime/src/jsii/_runtime.py index 70f24a6349..fed5f6bb29 100644 --- a/packages/jsii-python-runtime/src/jsii/_runtime.py +++ b/packages/jsii-python-runtime/src/jsii/_runtime.py @@ -105,6 +105,7 @@ def deco(fn): def implements(*interfaces): def deco(cls): + cls.__jsii_type__ = getattr(cls, "__jsii_type__", None) cls.__jsii_ifaces__ = getattr(cls, "__jsii_ifaces__", []) + list(interfaces) return cls From 0ebb7372371d09bd31bd89cc73f1fd255a4997d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Tue, 5 Nov 2019 13:40:41 +0100 Subject: [PATCH 6/8] fix some stuff up --- .../src/jsii/_kernel/__init__.py | 18 ++++++------------ .../src/jsii/_kernel/types.py | 5 ----- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py b/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py index 438598544d..7dcc4ecc03 100644 --- a/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py +++ b/packages/jsii-python-runtime/src/jsii/_kernel/__init__.py @@ -112,16 +112,16 @@ def wrapped(kernel, *args, **kwargs): # We need to recurse through our data structure and look for anything that the JSII # doesn't natively handle. These items will be created as "Object" types in the JSII. def _make_reference_for_native(kernel, d): - # Ugly delayed import here because I can't solve the cyclic - # package dependency right now :(. - from jsii._runtime import python_jsii_mapping - if isinstance(d, dict): return {"$jsii.map": {k: _make_reference_for_native(kernel, v) for k, v in d.items()}} elif isinstance(d, list): return [_make_reference_for_native(kernel, i) for i in d] if getattr(d, "__jsii_type__", None) is not None: + # Ugly delayed import here because I can't solve the cyclic + # package dependency right now :(. + from jsii._runtime import python_jsii_mapping + typeFqn = getattr(d, "__jsii_type__") mapping = python_jsii_mapping(d) if mapping: # This means we are handling a data_type (aka Struct) @@ -215,18 +215,12 @@ def create( if args is None: args = [] - overrides = _get_overides(klass, obj) - - interfaces = None - if klass.__jsii_ifaces__ is not None: - interfaces = [iface.__jsii_type__ for iface in klass.__jsii_ifaces__] - response = self.provider.create( CreateRequest( fqn=klass.__jsii_type__ or "Object", args=_make_reference_for_native(self, args), - overrides=overrides, - interfaces=interfaces, + overrides=_get_overides(klass, obj), + interfaces=[iface.__jsii_type__ for iface in getattr(klass, "__jsii_ifaces__", [])], ) ) if isinstance(response, Callback): diff --git a/packages/jsii-python-runtime/src/jsii/_kernel/types.py b/packages/jsii-python-runtime/src/jsii/_kernel/types.py index 60ea15e248..c8c6398937 100644 --- a/packages/jsii-python-runtime/src/jsii/_kernel/types.py +++ b/packages/jsii-python-runtime/src/jsii/_kernel/types.py @@ -249,11 +249,6 @@ def __jsii_type__(self) -> str: Returns a str that points to this class inside of the Javascript runtime. """ - def __jsii_ifaces__(self) -> Optional[List['JSClass']]: - """ - Returns an Optional[List['JSClass']] that represents interfaces implemented by this class (if any). - """ - class Referenceable(Protocol): @property def __jsii_ref__(self) -> ObjRef: From e414d9d239b89cefb1a5029c4c1ed96e734f3f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Tue, 5 Nov 2019 13:51:04 +0100 Subject: [PATCH 7/8] fix last broken test --- packages/jsii-python-runtime/tests/test_compliance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jsii-python-runtime/tests/test_compliance.py b/packages/jsii-python-runtime/tests/test_compliance.py index 8a36fa3cbf..19fe72d9b6 100644 --- a/packages/jsii-python-runtime/tests/test_compliance.py +++ b/packages/jsii-python-runtime/tests/test_compliance.py @@ -901,7 +901,7 @@ class PartiallyInitializedThisConsumerImpl(PartiallyInitializedThisConsumer): def consume_partially_initialized_this(self, obj, dt, en): assert obj is not None assert isinstance(dt, datetime) - assert en.member == AllTypesEnum.THIS_IS_GREAT.value + assert en == AllTypesEnum.THIS_IS_GREAT return "OK" reflector = PartiallyInitializedThisConsumerImpl() From 31321a04863a12c448ae94aacc95e346f6057352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Tue, 5 Nov 2019 14:25:46 +0100 Subject: [PATCH 8/8] fixup regression expectations --- packages/jsii-calc/test/assembly.jsii | 128 +++++++++++++++++++++++--- 1 file changed, 114 insertions(+), 14 deletions(-) diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 84be681318..77dda4c784 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -1249,7 +1249,7 @@ "kind": "class", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2096 + "line": 2143 }, "methods": [ { @@ -1258,7 +1258,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2099 + "line": 2146 }, "name": "ring", "overrides": "jsii-calc.IBell" @@ -1272,7 +1272,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2097 + "line": 2144 }, "name": "rung", "type": { @@ -2365,7 +2365,7 @@ "filename": "lib/compliance.ts", "line": 2034 }, - "name": "implementedByObjectLiteral", + "name": "staticImplementedByObjectLiteral", "parameters": [ { "name": "ringer", @@ -2391,7 +2391,7 @@ "filename": "lib/compliance.ts", "line": 2060 }, - "name": "implementedByPrivateClass", + "name": "staticImplementedByPrivateClass", "parameters": [ { "name": "ringer", @@ -2417,7 +2417,7 @@ "filename": "lib/compliance.ts", "line": 2049 }, - "name": "implementedByPublicClass", + "name": "staticImplementedByPublicClass", "parameters": [ { "name": "ringer", @@ -2443,7 +2443,7 @@ "filename": "lib/compliance.ts", "line": 2071 }, - "name": "whenTypedAsClass", + "name": "staticWhenTypedAsClass", "parameters": [ { "name": "ringer", @@ -2458,6 +2458,106 @@ } }, "static": true + }, + { + "docs": { + "remarks": "Returns whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using an object literal." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2081 + }, + "name": "implementedByObjectLiteral", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + } + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using a private class." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2107 + }, + "name": "implementedByPrivateClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + } + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "...if the interface is implemented using a public class." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2096 + }, + "name": "implementedByPublicClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + } + }, + { + "docs": { + "remarks": "Return whether the bell was rung.", + "stability": "experimental", + "summary": "If the parameter is a concrete class instead of an interface." + }, + "locationInModule": { + "filename": "lib/compliance.ts", + "line": 2118 + }, + "name": "whenTypedAsClass", + "parameters": [ + { + "name": "ringer", + "type": { + "fqn": "jsii-calc.IConcreteBellRinger" + } + } + ], + "returns": { + "type": { + "primitive": "boolean" + } + } } ], "name": "ConsumerCanRingBell" @@ -4152,7 +4252,7 @@ "kind": "interface", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2092 + "line": 2139 }, "methods": [ { @@ -4162,7 +4262,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2093 + "line": 2140 }, "name": "ring" } @@ -4179,7 +4279,7 @@ "kind": "interface", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2081 + "line": 2128 }, "methods": [ { @@ -4189,7 +4289,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2082 + "line": 2129 }, "name": "yourTurn", "parameters": [ @@ -4214,7 +4314,7 @@ "kind": "interface", "locationInModule": { "filename": "lib/compliance.ts", - "line": 2088 + "line": 2135 }, "methods": [ { @@ -4224,7 +4324,7 @@ }, "locationInModule": { "filename": "lib/compliance.ts", - "line": 2089 + "line": 2136 }, "name": "yourTurn", "parameters": [ @@ -10591,5 +10691,5 @@ } }, "version": "0.20.0", - "fingerprint": "/RixCfmN1ullwcAL5vmpSlGtU7F6Aw21XykcHTYQwsY=" + "fingerprint": "0Coq8NRof9rh1e1Bpj3IE6FnQn6vS2W2at5L+Baojhg=" }