by Player701 » Sun Nov 10, 2019 2:32 am
Okay, that other PR has been resolved, but there is still something important that has to be considered.
Take a look at the following ZScript:
Code: Select all
class A
{
virtual C GetSomething()
{
...
}
}
class B : A
{
D GetSomething() // Note: not virtual
{
...
}
}
class C
{
}
class D : C
{
}
As of now, this code compiles without errors. However, if the changes to implement this feature, they way I've coded it, are introduced, compilation will fail because of D::GetSomething missing the override qualifier.
This can be mitigated with a ZScript version bump. PClass::FindVirtualIndex could use the old, exact-matching algorithm to check return values in the old version, and the new algorithm to allow covariant return types in the new version.
If there are any objections to this particular issue, then I will probably give up on the PR, since otherwise it will require more extensive changes to ZCCCompiler::CompileFunction with a much greater risk to break something unintentionally. But then, I hope, it could eventually be done later by someone more experienced in this matter.
Okay, that other PR has been resolved, but there is still something important that has to be considered.
Take a look at the following ZScript:
[code]class A
{
virtual C GetSomething()
{
...
}
}
class B : A
{
D GetSomething() // Note: not virtual
{
...
}
}
class C
{
}
class D : C
{
}[/code]
As of now, this code compiles without errors. However, if the changes to implement this feature, they way I've coded it, are introduced, compilation will fail because of D::GetSomething missing the override qualifier.
This can be mitigated with a ZScript version bump. PClass::FindVirtualIndex could use the old, exact-matching algorithm to check return values in the old version, and the new algorithm to allow covariant return types in the new version.
If there are any objections to this particular issue, then I will probably give up on the PR, since otherwise it will require more extensive changes to ZCCCompiler::CompileFunction with a much greater risk to break something unintentionally. But then, I hope, it could eventually be done later by someone more experienced in this matter.