Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflection issues #304

Open
mastef opened this issue Nov 2, 2017 · 0 comments
Open

Reflection issues #304

mastef opened this issue Nov 2, 2017 · 0 comments
Labels

Comments

@mastef
Copy link
Contributor

mastef commented Nov 2, 2017

Could be related to #35

  • Issue 1 : When param type is unknown conversion doesn't happen
    ( see cases with paramNoType )
  • Issue 2 : Reflect.setField conversion is wrong for multiple level objects

as3 code for example:

package {
    public class Issue {
        public function Issue() {
            var paramNoType = "hello";
            if(this[paramNoType].bool == true)
            {
                this[paramNoType].bool = false;
                this[paramNoType].prop1.prop2 = "nothing";
            }

            var paramString:String = "hello";
            if(this[paramString].bool == true)
            {
                this[paramString].bool = false;
                this[paramString].prop1.prop2 = "nothing";
            }

            var paramDynamic:* = "hello";
            if(this[paramDynamic].bool == true)
            {
                this[paramDynamic].bool = false;
                this[paramDynamic].prop1.prop2 = "nothing";
            }
        }

        public function functionParamsTest(paramDynamic:*, paramString:String, paramNoType)
        {
            if(this[paramNoType].bool == true)
            {
                this[paramNoType].bool = false;
                this[paramNoType].prop1.prop2 = "nothing";
            }

            if(this[paramString].bool == true)
            {
                this[paramString].bool = false;
                this[paramString].prop1.prop2 = "nothing";
            }

            if(this[paramDynamic].bool == true)
            {
                this[paramDynamic].bool = false;
                this[paramDynamic].prop1.prop2 = "nothing";
            }
        }
    }
}

expected result

class Issue
{
    public function new()
    {
        var paramNoType = "hello";
        if (Reflect.field(Reflect.field(this, Std.string(paramNoType)), "bool") == true)
        {
            Reflect.setField(Reflect.field(this, Std.string(paramNoType)), "bool", false);
            Reflect.setField(Reflect.field(this, Std.string(paramNoType)).prop1, "prop2", "nothing");
        }
        
        var paramString : String = "hello";
        if (Reflect.field(Reflect.field(this, paramString), "bool") == true)
        {
            Reflect.setField(Reflect.field(this, paramString), "bool", false);
            Reflect.setField(Reflect.field(this, paramString).prop1, "prop2", "nothing");
        }
        
        var paramDynamic : Dynamic = "hello";
        if (Reflect.field(Reflect.field(this, Std.string(paramDynamic)), "bool") == true)
        {
            Reflect.setField(Reflect.field(this, Std.string(paramDynamic)), "bool", false);
            Reflect.setField(Reflect.field(this, Std.string(paramDynamic)).prop1, "prop2", "nothing");
        }
    }
    
    public function functionParamsTest(paramDynamic : Dynamic, paramString : String, paramNoType)
    {
        
        if (Reflect.field(Reflect.field(this, Std.string(paramNoType)), "bool") == true)
        {
            Reflect.setField(Reflect.field(this, Std.string(paramNoType)), "bool", false);
            Reflect.setField(Reflect.field(this, Std.string(paramNoType)).prop1, "prop2", "nothing");
        }
        
        if (Reflect.field(Reflect.field(this, paramString), "bool") == true)
        {
            Reflect.setField(Reflect.field(this, paramString), "bool", false);
            Reflect.setField(Reflect.field(this, paramString).prop1, "prop2", "nothing");
        }
        
        if (Reflect.field(Reflect.field(this, Std.string(paramDynamic)), "bool") == true)
        {
            Reflect.setField(Reflect.field(this, Std.string(paramDynamic)), "bool", false);
            Reflect.setField(Reflect.field(this, Std.string(paramDynamic)).prop1, "prop2", "nothing");
        }
    }
}

actual result

class Issue
{
    public function new()
    {
        var paramNoType = "hello";
        if (this[paramNoType].bool == true)
        {
            this[paramNoType].bool = false;
            this[paramNoType].prop1.prop2 = "nothing";
        }
        
        var paramString : String = "hello";
        if (Reflect.field(this, paramString).bool == true)
        {
            Reflect.setField(this, paramString, false).bool;
            Reflect.setField(this, paramString, "nothing").prop1.prop2;
        }
        
        var paramDynamic : Dynamic = "hello";
        if (Reflect.field(this, Std.string(paramDynamic)).bool == true)
        {
            Reflect.setField(this, Std.string(paramDynamic), false).bool;
            Reflect.setField(this, Std.string(paramDynamic), "nothing").prop1.prop2;
        }
    }
    
    public function functionParamsTest(paramDynamic : Dynamic, paramString : String, paramNoType)
    {
        if (this[paramNoType].bool == true)
        {
            this[paramNoType].bool = false;
            this[paramNoType].prop1.prop2 = "nothing";
        }
        
        if (Reflect.field(this, paramString).bool == true)
        {
            Reflect.setField(this, paramString, false).bool;
            Reflect.setField(this, paramString, "nothing").prop1.prop2;
        }
        
        if (Reflect.field(this, Std.string(paramDynamic)).bool == true)
        {
            Reflect.setField(this, Std.string(paramDynamic), false).bool;
            Reflect.setField(this, Std.string(paramDynamic), "nothing").prop1.prop2;
        }
    }
}
@SlavaRa SlavaRa added the bug label Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants