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

Covariant return vs. As3 #4222

Closed
Simn opened this issue May 15, 2015 · 0 comments
Closed

Covariant return vs. As3 #4222

Simn opened this issue May 15, 2015 · 0 comments

Comments

@Simn
Copy link
Member

Simn commented May 15, 2015

class Base {
    public function new() { }
    public function covariant():Base {
        return this;
    }
}

class Child extends Base {
    public override function covariant():Child {
        return this;
    }
}

class Main {
    static function main() {
        var c = new Child();
        var v = c.covariant();
    }
}

Generated As3:

package  {
    public class Main {
        static public function main() : void {
            var c : Child = new Child();
            var v : Child = c.covariant();
        }

    }
}

Fails in mxmlc with:

Main.as(6): col: 22 Error: Implicit coercion of a value with static type Base to a possibly unrelated type Child.

            var v : Child = c.covariant();
@Simn Simn closed this as completed in 5c675ab May 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant