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

abstract @:to not considered for static extensions #10435

Closed
frabbit opened this issue Oct 14, 2021 · 2 comments
Closed

abstract @:to not considered for static extensions #10435

frabbit opened this issue Oct 14, 2021 · 2 comments

Comments

@frabbit
Copy link
Member

frabbit commented Oct 14, 2021

Hi folks,

is the last expression in this example supposed to compile?

using Test.Usings;

class Usings {

    public static function withInt (m:Int):Int {
        return m;
    }

    public static function withString(m:String):String {
        return m;
    }
}

abstract Zapp(Int) to Int {

    @:to public function toString ():String return "";

}

function main () {
    var z:Zapp = cast null;
    z.withInt(); // works
    var y:String = z; // works
    z.withString(); // using fails to compile
}
@frabbit frabbit changed the title @:to not considered for static extensions abstract @:to not considered for static extensions Oct 14, 2021
@back2dos
Copy link
Member

Well, that's kinda by design: #5924

I guess a "smarter" way to deal with the problems I raised would be to first resolve extensions on the type itself and only then on types compatible via @:from/@:to casts. Although that still means that down the line the addition of more casts can affect the second selection pass in existent modules, either breaking things or silently selecting another extension.

@frabbit
Copy link
Member Author

frabbit commented Oct 22, 2021

Ah yes, thx for clarification.

@frabbit frabbit closed this as completed Oct 22, 2021
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

2 participants