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:
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
public ClassicSpriteSequenceLoader(ModData modData)
|
||||
: base(modData) { }
|
||||
|
||||
public override ISpriteSequence CreateSequence(
|
||||
public override ClassicSpriteSequence CreateSequence(
|
||||
ModData modData, string tileset, SpriteCache cache, string image, string sequence, MiniYaml data, MiniYaml defaults)
|
||||
{
|
||||
return new ClassicSpriteSequence(cache, this, image, sequence, data, defaults);
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
public ClassicTilesetSpecificSpriteSequenceLoader(ModData modData)
|
||||
: base(modData) { }
|
||||
|
||||
public override ISpriteSequence CreateSequence(
|
||||
public override ClassicTilesetSpecificSpriteSequence CreateSequence(
|
||||
ModData modData, string tileset, SpriteCache cache, string image, string sequence, MiniYaml data, MiniYaml defaults)
|
||||
{
|
||||
return new ClassicTilesetSpecificSpriteSequence(cache, this, image, sequence, data, defaults);
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
active = false;
|
||||
}
|
||||
|
||||
public override SupportPowerInstance CreateInstance(string key, SupportPowerManager manager)
|
||||
public override DischargeableSupportPowerInstance CreateInstance(string key, SupportPowerManager manager)
|
||||
{
|
||||
return new DischargeableSupportPowerInstance(key, info, manager);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
GetRotation = getRotation;
|
||||
}
|
||||
|
||||
public override Widget Clone()
|
||||
public override ModelWidget Clone()
|
||||
{
|
||||
return new ModelWidget(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user