I had thought that using the Top-Level Statements feature in C# 9 essentially wraps your top-level code in the usual Program class and Main method.
A decompiled top-level program looks like this:
[CompilerGenerated]
internal static class $Program
{
private static void $Main(string[] args)
{
// top-level code here
}
}
You can define normal methods at the top-level. They are compiled into the Program class, but outside of the Main method, where extension methods can also be defined.
Because the generated Program class is static and non-generic, I would expect to be able to define extension methods at the top level. However, I get compiler error CS1106: Extension method must be defined in a non-generic static class
Why is this?

