children method on Type returns empty array
Hello
I was doing some experimentation with reflection in Vala. Speficically the Type.children method seemed particularly useful in this case, but It seems to return an empty array when called, unless:
- The type is a class that inherits GLib.Object
- Instances of derived classes have been instantiated at least once before the call to
Type.children()
Here's some sample code to give you an idea of what I am talking about:
public interface expulsion : Object{
public abstract void sound();
}
public class cough : expulsion, Object{
public void sound(){
message("cough!");
}
}
public class sneeze : cough{
public void sound(){
message("atiuu!");
}
}
static void main(){
var children_of_ex = typeof(expulsion).children();
message(children_of_ex.length.to_string()); //produces 0 even if instances of cough and sneeze have been created
var children_of_cough = typeof(cough).children();
message(children_of_cough.length.to_string()); //also 0 but 1 if an instance of sneeze has been created
}
Is this expected behaviour?
Edited by Rico Tzschichholz