]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix checking access to async callback for base methods
authorLuca Bruno <lucabru@src.gnome.org>
Fri, 22 Apr 2011 17:28:42 +0000 (19:28 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Fri, 22 Apr 2011 17:35:10 +0000 (19:35 +0200)
Fixes regression introduced by 474611603ae6df7792f4dc2f107.

tests/Makefile.am
tests/asynchronous/bug646945.vala [new file with mode: 0644]
vala/valamemberaccess.vala

index c3c90d3ae1a070e34a2c4f64b2075707d594f997..d5f979d51b4164160a60f4d36df4dfd140b39720 100644 (file)
@@ -95,6 +95,7 @@ TESTS = \
        asynchronous/bug613484.vala \
        asynchronous/bug620740.vala \
        asynchronous/bug639591.vala \
+       asynchronous/bug646945.vala \
        asynchronous/closures.vala \
        dbus/basic-types.test \
        dbus/arrays.test \
diff --git a/tests/asynchronous/bug646945.vala b/tests/asynchronous/bug646945.vala
new file mode 100644 (file)
index 0000000..ad17d48
--- /dev/null
@@ -0,0 +1,20 @@
+class Foo : Object {
+       public virtual async void method1 () { }
+}
+
+interface Bar : Object {
+       public virtual async void method2 () { }
+}
+
+class Baz : Foo, Bar {
+       public override async void method1 () {
+               method1.callback ();
+       }
+
+       public async void method2 () {
+               method2.callback ();
+       }
+}
+
+void main () {
+}
index 26894ea69d2bab76536c91d12dbd37f23b84eff8..d7f66cd0cb44bf5c63be6de79547ddd933800bb6 100644 (file)
@@ -539,7 +539,17 @@ public class Vala.MemberAccess : Expression {
                                // and also for lambda expressions within async methods
                                var async_method = context.analyzer.current_async_method;
 
-                               if (async_method == null || m != async_method.get_callback_method ()) {
+                               bool is_valid_access = false;
+                               if (async_method != null) {
+                                       if (m == async_method.get_callback_method ()) {
+                                               is_valid_access = true;
+                                       } else if (async_method.base_method != null && m == async_method.base_method.get_callback_method ()) {
+                                               is_valid_access = true;
+                                       } else if (async_method.base_interface_method != null && m == async_method.base_interface_method.get_callback_method ()) {
+                                               is_valid_access = true;
+                                       }
+                               }
+                               if (!is_valid_access) {
                                        error = true;
                                        Report.error (source_reference, "Access to async callback `%s' not allowed in this context".printf (m.get_full_name ()));
                                        return false;