HaxeFoundation / HaxeFoundation/haxe
"Uncaught ReferenceError: Container_T is not defined" when trying to instantiate T from within nested generic classes
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
**Scenario**
* `class TestLogic extends Container `
* inherits from `class Container Void>> `
* uses a third class `GenericFactory` which offers a generic function to create arbitrary ``
* tested with html5 (JavaScript) target
**Problem**
When we call this method on TestLogic, it fails, because the type `` is not correctly resolved:
public function Generic():T {
trace("function Generic()");
var instance:T = Factory.CreateInstance(); // Uncaught ReferenceError: Container_T is not defined
return instance;
}
In comparison, the explicitly typed version works perfectly:
public function Typed():TestData {
trace("function Typed()");
var instance:TestData = Factory.CreateInstance(); // works
return instance;
}
**Testcase**
* https://try.haxe.org/#49dB2a5b
* see attachment
[Testcase.zip](https://github.com/HaxeFoundation/haxe/files/7892813/Testcase.zip)
Contributor guide
Assessment
This issue has not been assessed yet.