question: private void morph ( HGPersistentHandle instanceHandle , HGAtomType oldType , HGAtomType newType ) { HGPersistentHandle [ ] layout = store . getLink ( instanceHandle ) ; Object oldInstance = rawMake ( layout , oldType , instanceHandle ) ; TypeUtils . releaseValue ( this , oldType , layout [ 1 ] ) ; indexByValue . removeEntry ( layout [ 1 ] , instanceHandle ) ; layout [ 1 ] = TypeUtils . storeValue ( this , oldInstance , newType ) ; indexByValue . addEntry ( layout [ 1 ] , instanceHandle ) ; store . store ( instanceHandle , layout ) ; Object newInstance = rawMake ( layout , newType , instanceHandle ) ; HGLiveHandle instanceLiveHandle = cache . get ( instanceHandle ) ; if ( instanceLiveHandle != null && instanceLiveHandle . getRef ( ) != null ) cache . atomRefresh ( instanceLiveHandle , newInstance , true ) ; if ( oldInstance instanceof HGAtomType ) { HGSearchResult < HGPersistentHandle > rs = null ; try { rs = indexByType . find ( instanceHandle ) ; if ( rs . hasNext ( ) && ! ( newInstance instanceof HGAtomType ) ) throw new HGException ( "Cannot replace value of atom " + instanceHandle + " which was a type with something that is not a type" ) ; oldType = ( HGAtomType ) oldInstance ; newType = ( HGAtomType ) newInstance ; while ( rs . hasNext ( ) ) { morph ( ( HGPersistentHandle ) rs . next ( ) , oldType , newType ) ; } } finally { if ( rs != null ) rs . close ( ) ; } } }
target:  Change the type value of an atom value. It is assumed that oldType and newType keep the same handle. This is used when we are replacing the value of a type atom with another value (which must be a compatible type value). Morphing can potentially lead to a different run-time instance of the atom. So, if the atom is "alive", we replace the run-time instance.