2

It's a known fact builtin types like Int32/Double/... are implemented on compiler level, and users cannot implement recursive structs like Int32:

public readonly struct Int32 : IComparable, IConvertible, IFormattable, IComparable<int>, IEquatable<int>, ISpanFormattable
{
    private readonly int m_value; // Do not rename (binary serialization)

Considering int to be an alias to Int32 we have an unsolvable recursion here. But it's fine since it get compiler's "special comprehension".

However, I wonder why it contains any implementation at all. If you look at the file you can see that there is code that real runtime seems to actually use.

I wonder why bultin types are not just stubs? I firstly imagined that it may be used as implementation of the boxed value, but it doesn't work to me since it's declared as struct. However, with compiler black magic everything becomes possible. But I don't know for sure.

Alex Zhukovskiy
  • 9,565
  • 11
  • 75
  • 151

0 Answers0