Skip to content

Commit

Permalink
referenceIO.toStateObject asserts instrumentation, #312
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kauzmann <[email protected]>
  • Loading branch information
zepumph committed Jul 19, 2024
1 parent eb8d2f1 commit 4411368
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions js/types/ReferenceIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import IOType from './IOType.js';
import StringIO from './StringIO.js';
import { PhetioID } from '../TandemConstants.js';
import IOTypeCache from '../IOTypeCache.js';
import Tandem from '../Tandem.js';

// Cache each parameterized ReferenceIO so that it is only created once
const cache = new IOTypeCache();
Expand All @@ -41,6 +42,7 @@ const ReferenceIO = ( parameterType: IOType ): IOType => {
* directly to use this implementation.
*/
toStateObject( phetioObject ): ReferenceIOState {
assert && Tandem.VALIDATION && assert( phetioObject.isPhetioInstrumented(), 'Cannot reference an uninstrumented object', phetioObject );

// NOTE: We cannot assert that phetioObject.phetioState === false here because sometimes ReferenceIO is used statically like
// ReferenceIO( Vector2IO ).toStateObject( myVector );
Expand Down

0 comments on commit 4411368

Please sign in to comment.