From: Luca Bruno Date: Fri, 22 Apr 2011 17:28:42 +0000 (+0200) Subject: Fix checking access to async callback for base methods X-Git-Tag: 0.13.0~216 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ee54bf41b8cf4ea29bb673e75557014a5f83d9f;p=thirdparty%2Fvala.git Fix checking access to async callback for base methods Fixes regression introduced by 474611603ae6df7792f4dc2f107. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index c3c90d3ae..d5f979d51 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..ad17d486b --- /dev/null +++ b/tests/asynchronous/bug646945.vala @@ -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 () { +} diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala index 26894ea69..d7f66cd0c 100644 --- a/vala/valamemberaccess.vala +++ b/vala/valamemberaccess.vala @@ -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;