Skip to content

Commit

Permalink
fix: review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Nov 6, 2023
1 parent 7460a13 commit 94389ad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
10 changes: 8 additions & 2 deletions packages/exo/src/exo-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,10 @@ export const defendPrototype = (
);
}

if (interfaceGuard) {
if (!hasOwnPropertyOf(prototype, GET_INTERFACE_GUARD)) {
const getInterfaceGuardMethod = {
[GET_INTERFACE_GUARD]() {
// Note: May be `undefined`
return interfaceGuard;
},
}[GET_INTERFACE_GUARD];
Expand All @@ -441,7 +442,12 @@ export const defendPrototype = (
);
}

return Far(tag, /** @type {T} */ (prototype));
return Far(
tag,
/** @type {T & import('./get-interface.js').GetInterfaceGuard<T>} */ (
prototype
),
);
};
harden(defendPrototype);

Expand Down
7 changes: 4 additions & 3 deletions packages/exo/src/get-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export const GET_INTERFACE_GUARD = Symbol.for('getInterfaceGuard');
/**
* @template {Record<PropertyKey, CallableFunction>} M
* @typedef {{
* [GET_INTERFACE_GUARD]: () => import('@endo/patterns').InterfaceGuard<{
* [K in keyof M]: import('@endo/patterns').MethodGuard
* }>
* [GET_INTERFACE_GUARD]: () =>
* import('@endo/patterns').InterfaceGuard<{
* [K in keyof M]: import('@endo/patterns').MethodGuard
* }> | undefined
* }} GetInterfaceGuard
*/
2 changes: 0 additions & 2 deletions packages/exo/test/test-exo-class-js-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import { test } from './prepare-test-env-ava.js';

import { passStyleOf } from '@endo/pass-style';
// import { M, getInterfaceGuardPayload } from '@endo/patterns';
// import { defineExoClass, makeExo } from '../src/exo-makers.js';
import { M, getInterfaceGuardPayload } from '@endo/patterns';
import { makeExo, defineExoClass } from '../src/exo-makers.js';

Expand Down
4 changes: 1 addition & 3 deletions packages/exo/test/test-heap-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ test('missing interface', t => {
message:
'In "makeSayHello" method of (greeterMaker): result: "[Symbol(passStyle)]" property expected: "[Function <anon>]"',
});
t.throws(() => greeterMaker[GET_INTERFACE_GUARD](), {
message: 'greeterMaker[GET_INTERFACE_GUARD] is not a function',
});
t.is(greeterMaker[GET_INTERFACE_GUARD](), undefined);
});

const SloppyGreeterI = M.interface('greeter', {}, { sloppy: true });
Expand Down

0 comments on commit 94389ad

Please sign in to comment.