Found a weird problem about AudioSource.PlayOneShot

AudioSource _AudioSource_1 = new GameObject().GetComponent<AudioSource>();
AudioSource _AudioSource_2 = null;
Debug.Log(_AudioSource_1.Equals(_AudioSource_2));
_AudioSource_1.PlayOneShot(new AudioClip());
Debug.Log("Pass1");
_AudioSource_2.PlayOneShot(new AudioClip());
Debug.Log("Pass2");

88661-88655-playoneshot.png
Here is my code and what console displayed.
I’d appreciate it if someone could tell me why this
_AudioSource_1.PlayOneShot(new AudioClip());
can pass.

I know that unity overloaded null, maybe equals also, for several reasons. you are, somehow, successfully using the constructor on the returned AudioSource. maybe it creates a new instance but overrides null so that it’s not pointing to any legal C++ native component anymore effectively comparing nulls.
don’t use new on any unity class. use AddComponent if you need another.

I did some research and found, truly like @hexagonius said, unity overrided something like Equals, == and != to build a Null Object pattern.
So here is my code to test:

AudioSource _AudioSource_1 = new GameObject().GetComponent<AudioSource>();
Debug.Log(object.Equals(_AudioSource_1,  
FormatterServices.GetUninitializedObject(typeof(AudioSource))));
Debug.Log(_AudioSource_1.GetType());
Debug.Log(_AudioSource_1);
_AudioSource_1.PlayOneShot(null);
Debug.Log("Pass1");

And Console:
88728-nulltest.png
It looks like GetComponent will always return reference of a T type instance if T is a NATIVE component type, whether or not there is a T component attached to the gameobject.

But when you want to get a custom component, if there is no one attached, GetComponent will definitely return a real null. Like this:

GameDataState _GameDataState = new GameObject().GetComponent<GameDataState>();
Debug.Log(object.Equals(_GameDataState, null));
Debug.Log(_GameDataState.enabled);
Debug.Log("Pass");

88729-customecomponent.png
It would yield a NullReferenceException.
So you can see unity overrided some method to make you think it’s null when you try to get a not attached component, and i think maybe they forgot to deal with this PlayOneShot method so it can be invoked.