COMMUNITY

Issue with Nested Function Call "Field has no expression (possible typing order issue)"

I’ve been having an issue where i need to loop over items recursively to determine if the object of a certain type exists and for some reason i’m getting an error.


	public function getComponentsInChildren(c:Class<Dynamic>, list:Vector<Component> = null):Vector<Component>
    {
        if(list == null) list = new Vector<Component>();
        var componentList = _getComponents(c);
        for(i in 0...componentList.length){
            list[list.length] = componentList[i];    
        }
        for (i in 0..._renderList.length){
            if(Std.is(_renderList[i], WorldItem)){
                var child = cast(_renderList[i],WorldItem<Dynamic>);
                //TODO: Fix or findout what the issue is with this line of code
                child.getComponentsInChildren(c, list);
                
            }
        }
        
        return list;
    }

the line with

child.getComponentsInChildren(c, list);

throws the following error: Field getComponentsInChildren has no expression (possible typing order issue)

while if i rewrite it to the following i have no issues

    private function _getComponentsInChildrenByReference(ref:WorldItem<Dynamic>, c:Class<Dynamic>, list:Vector<Component> = null):Vector<Component>
    {
        if(list == null) list = new Vector<Component>();
        var componentList = ref.getComponents(c);
        for(i in 0...componentList.length){
            list[list.length] = componentList[i];    
        }
        for (i in 0..._renderList.length){
            if(Std.is(_renderList[i], WorldItem)){
                var child = cast(_renderList[i],WorldItem<Dynamic>);
                _getComponentsInChildrenByReference(child , c, list);
            }
        }

        return list;
    }

Is there any way to fix the issue on the first example of nested functionality, i would much better prefer it, as it’s a much cleaner way to interact with the code.

Is there anything else i should look for or that i may be doing incorrectly.

Any assistance would be greatly appreciated.

EDIT:

Also be aware that the class definition is:

@:generic
class WorldItem<T:DisplayObjectContainer & Constructible<Void->Void>> extends Container<T> {

not sure if that is relevant.

This looks like a compiler issue. Could you please assemble a self-contained sample?

I’ll see if i can come up with something.