This code fails to compile:
public class Component<T1>
{
public virtual void Foo(T1 t1)
{
return;
}
}
public class Panel<T1>
where T1: Component<Panel<T1>>
{
public void Bar() {
Console.WriteLine("Win");
}
}
public class MyFormPanel : Panel<MyFormPanel.Form>
{
public class Form : Component<MyFormPanel>
{
public override void Foo(MyFormPanel t1)
{
t1.Bar();
}
}
}
The error given is that the the MyFromPanel.Form
cannot be used as a type parameter T1 since there is no implicit reference conversion from MyFormPanel.Form
to Component<Panel<MyFormPanel.Form>>
This seems confusing to me because a Form inherits from Component, where MyFormPanel is a Panel. Why is this error happening then?