Closed serjek closed 4 years ago
Thanks @serjek, a future approach we could take (which might involve changing the schema-codegen
a bit) would be to use Type.resolveClass()
to get the specific constructor of generic type from MapSchema
/ArraySchema
, like this:
(Playground link: https://try.haxe.org/#FC2A5)
@:keep
@:generic
class MyMap<T> {
public var child: T;
public function new() {}
}
@:keep
class MyItem {}
class Test {
static function main() {
var mapOfString = new MyMap<String>();
var mapOfNumber = new MyMap<Int>();
var mapOfItems = new MyMap<MyItem>();
var instance = Type.createInstance(Type.resolveClass("MyMap_MyItem"), []);
trace(Type.getClassName(Type.resolveClass("MyMap_MyItem")));
}
}
This happens because previousValue is
null
, as it is pointed out in Schema:560. Suggestion is to replace this:with this: