[cpp] Add missing override specifiers#12840
[cpp] Add missing override specifiers#12840tobil4sk wants to merge 4 commits intoHaxeFoundation:developmentfrom
Conversation
Adding overrides explicitly has revealed a potential bug in this test case. Even though Baz.fun looks like it is overriding Foo.fun, this is not actually the case because Foo is generated as non-virtual and therefore cannot be overridden. This may be a bug with nativeGen.
|
@Aidan63 does this seem good to you? You mentioned you ran into some weird issues when you last tried this. |
|
I think this looks good. I'm guessing I was getting tripped up by marking all |
|
Yeah the I guess I should also check that a virtual toString in a Btw, in that test case that I had to modify: @:nativeGen
@:structAccess
private class Foo {
// ...
public function fun() return /*...*/;
}The problem is that Foo.fun is not overridden in any haxe code, so it assumes it is non virtual. Do you know if there is any way to tell haxe that |
|
For native gen classes you might just have to assume that every function is virtual unless otherwise specified (final, nonVirtual), since thats the haxe semantics. I don't think there's any work around for that. |
|
I think haxe decides somewhere else to make it non-virtual, because otherwise I'm testing this with haxe 4 and nightly: @:nativeGen // or commented out
class Parent {
public function fun() return 42;
}
@:nativeGen
class Child extends Parent {
override function fun() return 10;
}If I comment out |
Together with HaxeFoundation/hxcpp#1319, this fixes warnings about missing overrides that show up when compiling a hxcpp program.
These were already present in a few places, and it is fine to add them because the minimum c++ version for haxe 5 is already c++11. It is good practice to have these to help catch issues like #11666, where a method is overloaded instead of overridden.
I had to modify the test for #9516, because adding these revealed a possible bug. Despite
overridein haxe code,Baz.funwas never actually overridingBar.fun, becauseFoois marked as@:nativeGen. This happens even with haxe 4.3.7, but is only revealed when theseoverridespecifiers are added.