From 33a30c38c95906395b397eaf75acc1c21d1e3f96 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Thu, 22 Aug 2024 15:40:45 -0600 Subject: [PATCH] Reapply "referenceIO.toStateObject asserts instrumentation, https://github.com/phetsims/tandem/issues/312" This reverts commit 2fbf982207875b05d3441a8da059b0a8e7930097. --- js/types/ReferenceIO.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/types/ReferenceIO.ts b/js/types/ReferenceIO.ts index acc47f55..afccddd5 100644 --- a/js/types/ReferenceIO.ts +++ b/js/types/ReferenceIO.ts @@ -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(); @@ -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 );