HaxeFoundation / HaxeFoundation/haxe

[flash] calling overriden protected method will fail at run-time

Open
#8,289 3 comments 0 reactions 0 assignees View on GitHub
bug platform-flash
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Another corner-case with protecteds in the SWF generator:

```haxe
class A {
@:protected function f() return 10;
}

class B extends A {
override function f() return 20;

public function new() {
trace(f());
}
}

class Main{
static function main() {
new B();
}
}
```

This will fail at run-time with `TypeError: Error #1006: f is not a function.`, because the `f` access in `B.new` has invalid namespace specifier. It should be the protected namespace, but is public instead. This is because the overriden `f` doesn't have `@:protected` meta itself and genswf9 doesn't check whether it overrides a protected method or not.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.