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:
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
foreach (var panel in panels)
|
||||
{
|
||||
var container = panelTemplate.Clone() as ContainerWidget;
|
||||
var container = panelTemplate.Clone();
|
||||
container.Id = panel.Key;
|
||||
panelContainer.AddChild(container);
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
ButtonWidget AddSettingsTab(string id, string label)
|
||||
{
|
||||
var tab = tabTemplate.Clone() as ButtonWidget;
|
||||
var tab = tabTemplate.Clone();
|
||||
var lastButton = buttons.LastOrDefault();
|
||||
if (lastButton != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user