This repository was archived by the owner on Aug 31, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-12
lines changed
Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -719,18 +719,26 @@ MCScriptExecuteContext::UnboxingConvert(MCValueRef p_value,
719719 const MCForeignTypeDescriptor *t_from_desc =
720720 MCForeignTypeInfoGetDescriptor (t_resolved_from_type.type );
721721
722- // If the source is foreign, then it must be the bridge type
723- // of the slot, so we must import.
724- MCValueRef t_bridged_value;
725- if (!t_from_desc->doimport (MCForeignValueGetContentsPtr (p_value),
726- false ,
727- t_bridged_value))
728- {
729- Rethrow ();
730- return false ;
731- }
732-
733- *(MCValueRef *)x_slot_ptr = t_bridged_value;
722+ // If the type of the destination slot is not exactly the foreign type,
723+ // import as the bridge type.
724+ if (t_from_desc->bridgetype != kMCNullTypeInfo &&
725+ t_resolved_from_type.type != p_slot_type.type )
726+ {
727+ MCValueRef t_bridged_value;
728+ if (!t_from_desc->doimport (MCForeignValueGetContentsPtr (p_value),
729+ false ,
730+ t_bridged_value))
731+ {
732+ Rethrow ();
733+ return false ;
734+ }
735+
736+ *(MCValueRef *)x_slot_ptr = t_bridged_value;
737+ }
738+ else
739+ {
740+ *(MCValueRef *)x_slot_ptr = MCValueRetain (p_value);
741+ }
734742 }
735743 else if (MCTypeInfoIsHandler (p_slot_type.type ) &&
736744 MCHandlerTypeInfoIsForeign (p_slot_type.type ))
You can’t perform that action at this time.
0 commit comments