Skip to content

Commit

Permalink
fix(kernel): Correctly return instances of un-exported types
Browse files Browse the repository at this point in the history
When an un-exported type that extends an exported type is returned with
an interface as the declared type, the JSII kernel used to return a ref
with the FQN of the exported supertype, instead of correctly wrapping
the instance in a proxy of the interface type as it should have.

Fixes #302
  • Loading branch information
RomainMuller committed Nov 26, 2018
1 parent 151af56 commit fb46f02
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/jsii-kernel/lib/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,9 @@ export class Kernel {
// have an object id, so we need to allocate one for it.
this._debug('creating objref for', v);
const fqn = this._fqnForObject(v);
return this._createObjref(v, fqn);
if (!targetType || !spec.isNamedTypeReference(targetType) || fqn === targetType.fqn) {
return this._createObjref(v, fqn);
}
}

// if the method/property returns an object literal and the return type
Expand Down

0 comments on commit fb46f02

Please sign in to comment.