/// </summary>
public static DefType GetClosestDefType(this TypeDesc type)
{
- if (type.IsArray)
- {
- if (!type.IsArrayTypeWithoutGenericInterfaces())
- {
- MetadataType arrayShadowType = type.Context.SystemModule.GetType("System", "Array`1", throwIfNotFound: false);
- if (arrayShadowType != null)
- {
- return arrayShadowType.MakeInstantiatedType(((ArrayType)type).ElementType);
- }
- }
-
- return type.Context.GetWellKnownType(WellKnownType.Array);
- }
-
- Debug.Assert(type is DefType);
- return (DefType)type;
+ return ((CompilerTypeSystemContext)type.Context).GetClosestDefType(type);
}
/// <summary>
private TypeDesc[] _arrayOfTInterfaces;
private ArrayOfTRuntimeInterfacesAlgorithm _arrayOfTRuntimeInterfacesAlgorithm;
+ private MetadataType _arrayOfTType;
public CompilerTypeSystemContext(TargetDetails details, SharedGenericsMode genericsMode, DelegateFeature delegateFeatures)
: base(details)
return new DelegateInfo(delegateType, _delegateFeatures);
}
+ internal DefType GetClosestDefType(TypeDesc type)
+ {
+ if (type.IsArray)
+ {
+ if (!type.IsArrayTypeWithoutGenericInterfaces())
+ {
+ MetadataType arrayShadowType = _arrayOfTType ?? (_arrayOfTType = SystemModule.GetType("System", "Array`1"));
+ return arrayShadowType.MakeInstantiatedType(((ArrayType)type).ElementType);
+ }
+
+ return GetWellKnownType(WellKnownType.Array);
+ }
+
+ Debug.Assert(type is DefType);
+ return (DefType)type;
+ }
+
private readonly LazyGenericsSupport.GenericCycleDetector _genericCycleDetector = new LazyGenericsSupport.GenericCycleDetector();
public void DetectGenericCycles(TypeSystemEntity owner, TypeSystemEntity referent)
{
_genericsMode = genericsMode;
}
+
+ internal DefType GetClosestDefType(TypeDesc type)
+ {
+ if (type.IsArray)
+ {
+ return GetWellKnownType(WellKnownType.Array);
+ }
+
+ Debug.Assert(type is DefType);
+ return (DefType)type;
+ }
}
public partial class ReadyToRunCompilerContext : CompilerTypeSystemContext