Use covariant return types.

Use the covariant return type feature of C# 9 to allow method overrides to be more specific about their return type. By exposing this information, e.g. for Widget.Clone(), callers will have more information. This allows various casts to be removed as the information is now available within the type system.
This commit is contained in:
RoosterDragon
2024-09-21 12:08:15 +01:00
committed by Gustas
parent 9c568aba33
commit aa121dcb2f
54 changed files with 60 additions and 62 deletions

View File

@@ -631,7 +631,7 @@ namespace OpenRA.Widgets
}
public override string GetCursor(int2 pos) { return null; }
public override Widget Clone() { return new ContainerWidget(this); }
public override ContainerWidget Clone() { return new ContainerWidget(this); }
public override bool HandleMouseInput(MouseInput mi)
{
@@ -655,7 +655,7 @@ namespace OpenRA.Widgets
IsDisabled = () => other.Disabled;
}
public override Widget Clone() { return new InputWidget(this); }
public override InputWidget Clone() { return new InputWidget(this); }
}
public class WidgetArgs : Dictionary<string, object>