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

Closure field assignment generates bad code #2

Open
zeen opened this issue Jun 26, 2013 · 0 comments
Open

Closure field assignment generates bad code #2

zeen opened this issue Jun 26, 2013 · 0 comments

Comments

@zeen
Copy link

zeen commented Jun 26, 2013

Assigning a closure to a class field generates code which doesn't compile. It fails in different ways depending on whether it's assigned from outside the class, or inside, and whether the field is static or non-static.

import objc.foundation.NSDictionary;
import ios.ui.UIApplicationMain;
import ios.ui.UIApplicationDelegate;
import ios.ui.UIResponder;
import ios.ui.UIApplication;
import ios.ui.UIWindow;

class MyClass {
    public var closure :String->Void;
    public function new() {}
}

class ClosureTest extends UIResponder implements UIApplicationDelegate {

    public static function test() {
        trace("Before");
        var x = new MyClass();
        x.closure = function(s) { trace(s); };
        x.closure("Closure!");
        trace("After");
    }

    public static function main() { return new UIApplicationMain ( ClosureTest ); }
    public static function unusedMain(){}
    public var window :UIWindow;
    public function application (application:UIApplication, didFinishLaunchingWithOptions:NSDictionary) :Bool {
        test();
        return true;
    }
    public function applicationDidBecomeActive (application:UIApplication) :Void {}
    public function applicationWillResignActive (application:UIApplication) :Void {}
}
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