@@ -18,6 +18,8 @@ HRESULT CLR_RT_HeapBlock_Array::CreateInstance(
1818 CLR_RT_HeapBlock_Array *pArray;
1919 CLR_RT_TypeDef_Index cls;
2020 CLR_RT_TypeDef_Instance inst{};
21+ CLR_RT_TypeDescriptor desc{};
22+ CLR_RT_ReflectionDef_Index workingReflex = reflex;
2123
2224 reference.SetObjectReference (nullptr );
2325
@@ -26,12 +28,31 @@ HRESULT CLR_RT_HeapBlock_Array::CreateInstance(
2628
2729 if (reflex.kind != REFLECTION_TYPE)
2830 {
29- NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
31+ // check for typespec
32+ if (reflex.kind == REFLECTION_TYPESPEC)
33+ {
34+ // get the type descriptor for the typespec
35+ (desc.InitializeFromTypeSpec (reflex.data .typeSpec ));
36+
37+ // check that this ends up being a reflecion type
38+ if (desc.m_reflex .kind != REFLECTION_TYPE)
39+ {
40+ NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
41+ }
42+
43+ // copy over to working reflex
44+ workingReflex = desc.m_reflex ;
45+ workingReflex.levels ++;
46+ }
47+ else
48+ {
49+ NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
50+ }
3051 }
3152
32- if (reflex .levels == 1 )
53+ if (workingReflex .levels == 1 )
3354 {
34- cls = reflex .data .type ;
55+ cls = workingReflex .data .type ;
3556 }
3657 else
3758 {
0 commit comments