Skip to content

Commit

Permalink
fix(kernel): revert behavior change around any serialization (#932)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RomainMuller committed Nov 5, 2019
1 parent 068578a commit 2f47543
Show file tree
Hide file tree
Showing 28 changed files with 1,990 additions and 137 deletions.
138 changes: 138 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2017,3 +2017,141 @@ 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 staticImplementedByObjectLiteral(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 staticImplementedByPublicClass(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 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;
}

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;
}
}
Loading

0 comments on commit 2f47543

Please sign in to comment.