static constructor not called when class is accessed via static methods
Submitted by Stef Walter
Link to original bug (#543189)
Description
The static construct block of a class is executed before a new object of that type is created. However I would expect it to be executed when static methods are called.
Example:
/*
* valac test.vala
*/
using GLib;
public class Statico : GLib.Object {
public static int test_value;
static construct {
test_value = 5;
}
public static int get_test_value() {
return test_value;
}
}
public class Test : GLib.Object {
public static void main(string[] args) {
/* Should print '5', but prints '0' */
stdout.printf("%d\n", Statico.get_test_value());
}
}