A class code which crashes Unity Editor

I got abnormal code which is compiled but crashes Unity editor when it runs.

public class SpawnEvent : IEvent 
{
    public enum Type
    {
        Avatar,
        Player, // other player character
        NPC,
        Monster,
    }

    public GameObject spawnnedObject;

    public Type type;

    public override object GetData()
    {
        return spawnnedObject;
    }

    public override string GetName()
    {
        return this.GetType().ToString();
    }
}

When it was initialized anywhere in other code side like that:

    SpawnEvent spawnEvent = new SpawnEvent();

Unity editor is crashed. But when I modified the above class like that: (I modified Type enum to SpawnType)

public class SpawnEvent : IEvent 
{
    public enum SpawnType
    {
        Avatar,
        Player, // other player character
        NPC,
        Monster,
    }

    public GameObject spawnnedObject;

    public SpawnType spawnType;

    public override object GetData()
    {
        return spawnnedObject;
    }

    public override string GetName()
    {
        return this.GetType().ToString();
    }
}

It runs ok.

Any ideas?

There is a type called System.Type defined in the Mono library which is fundamental to the operation of the runtime. It is likely that you have introduced some kind of conflict by declaring your own enum with the same name.

I got it, thank you for the reply.

BTW, it’s wonder why the compiler does not spit any warning out.

Thank you.