I want to deserialize an object with properties. The object is well constructed but setters/getters are not correctly instancied if I don't type explicitly my object.
Is it an intended behavior or a bug ?
Minimal example:
package models;
class TestClass
{
public var test(default, set): String;
public function set_test(myVar) {
trace("Set " + myVar);
return test = myVar;
}
}
class Main
{
public function new()
{
var typedTest: TestClass = Type.createInstance(Type.resolveClass("models.TestClass"), []);
var untypedTest = Type.createInstance(Type.resolveClass("models.TestClass"), []);
trace(Type.getClassName(Type.getClass(typedTest))); //"models.TestClass"
trace(Type.getClassName(Type.getClass(untypedTest ))); //"models.TestClass"
typedTest.test = "12"; // "Set 12"
untypedTest.test = "15"; //nothing happens here
Reflect.setProperty(untypedTest, "test", "18"); // "Set 18"
}
}
I'm kinda confused about this one.
Aucun commentaire:
Enregistrer un commentaire