@@ -2728,13 +2728,25 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
27282728 {
27292729 FETCH_ARG_COMPRESSED_FIELDTOKEN (arg, ip);
27302730
2731- CLR_RT_FieldDef_Instance field;
2731+ CLR_RT_FieldDef_Instance field{};
2732+ CLR_RT_HeapBlock *ptr = nullptr ;
2733+
2734+ // resolve field token
27322735 if (field.ResolveToken (arg, assm, &stack->m_call ) == false )
27332736 {
27342737 NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
27352738 }
27362739
2737- CLR_RT_HeapBlock *ptr = CLR_RT_ExecutionEngine::AccessStaticField (field);
2740+ if (field.genericType && NANOCLR_INDEX_IS_VALID (*field.genericType ))
2741+ {
2742+ // access static field of a generic instance
2743+ ptr = field.assembly ->GetStaticFieldByFieldDef (field, field.genericType );
2744+ }
2745+ else
2746+ {
2747+ // static field of a non-generic class
2748+ ptr = CLR_RT_ExecutionEngine::AccessStaticField (field);
2749+ }
27382750
27392751 if (ptr == nullptr )
27402752 {
@@ -2756,13 +2768,25 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
27562768 {
27572769 FETCH_ARG_COMPRESSED_FIELDTOKEN (arg, ip);
27582770
2759- CLR_RT_FieldDef_Instance field;
2771+ CLR_RT_FieldDef_Instance field{};
2772+ CLR_RT_HeapBlock *ptr = nullptr ;
2773+
2774+ // resolve field token
27602775 if (field.ResolveToken (arg, assm, &stack->m_call ) == false )
27612776 {
27622777 NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
27632778 }
27642779
2765- CLR_RT_HeapBlock *ptr = CLR_RT_ExecutionEngine::AccessStaticField (field);
2780+ if (field.genericType && NANOCLR_INDEX_IS_VALID (*field.genericType ))
2781+ {
2782+ // access static field of a generic instance
2783+ ptr = field.assembly ->GetStaticFieldByFieldDef (field, field.genericType );
2784+ }
2785+ else
2786+ {
2787+ // static field of a non-generic class
2788+ ptr = CLR_RT_ExecutionEngine::AccessStaticField (field);
2789+ }
27662790
27672791 if (ptr == nullptr )
27682792 {
@@ -2783,13 +2807,25 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
27832807 {
27842808 FETCH_ARG_COMPRESSED_FIELDTOKEN (arg, ip);
27852809
2786- CLR_RT_FieldDef_Instance field;
2810+ CLR_RT_FieldDef_Instance field{};
2811+ CLR_RT_HeapBlock *ptr = nullptr ;
2812+
2813+ // resolve field token
27872814 if (field.ResolveToken (arg, assm, &stack->m_call ) == false )
27882815 {
27892816 NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
27902817 }
27912818
2792- CLR_RT_HeapBlock *ptr = CLR_RT_ExecutionEngine::AccessStaticField (field);
2819+ if (field.genericType && NANOCLR_INDEX_IS_VALID (*field.genericType ))
2820+ {
2821+ // access static field of a generic instance
2822+ ptr = field.assembly ->GetStaticFieldByFieldDef (field, field.genericType );
2823+ }
2824+ else
2825+ {
2826+ // static field of a non-generic class
2827+ ptr = CLR_RT_ExecutionEngine::AccessStaticField (field);
2828+ }
27932829
27942830 if (ptr == nullptr )
27952831 {
0 commit comments