Beef
Beef copied to clipboard
"Only one destructor allowed" error when using EmitTypeBody in a class with an extension destructor
The code below fails to compile with the error "Only one destructor allowed".
This error occurs only if EmitTypeBody emits any code and both the extension and the extension's base class have a destructor.
class X<T>
{
~this()
{
}
[OnCompile(.TypeInit), Comptime]
static void Init()
{
String emitStr = """
public void Test() {}
""";
Compiler.EmitTypeBody(typeof(Self), emitStr);
}
}
extension X<T> where T : IDisposable
{
~this()
{
}
}
class Program
{
public static int Main()
{
X<String> a = scope .();
}
}
Tested with: 9c9d29d493b06328d64b48edcb1b07d57406c2a0