bool AssertCanCreateInstance(Node sourceNode, IType type)
{
if (type.IsInterface)
{
Error(CompilerErrorFactory.CantCreateInstanceOfInterface(sourceNode, type));
return false;
}
if (type.IsEnum)
{
Error(CompilerErrorFactory.CantCreateInstanceOfEnum(sourceNode, type));
return false;
}
if (type.IsAbstract)
{
Error(CompilerErrorFactory.CantCreateInstanceOfAbstractType(sourceNode, type));
return false;
}
if (!(type is GenericConstructedType)
&& ((type.GenericInfo != null && type.GenericInfo.GenericParameters.Length > 0)
|| (type.ConstructedInfo != null && !type.ConstructedInfo.FullyConstructed)))
{
Error(CompilerErrorFactory.GenericTypesMustBeConstructedToBeInstantiated(sourceNode));
return false;
}
return true;
}