From: Luca Bruno Date: Thu, 26 May 2011 18:57:01 +0000 (+0200) Subject: Fix checking for abstract/virtual methods inside structs X-Git-Tag: 0.13.0~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d3e6cd3b4612d0530f026fc5cc86a38ee1ba24f;p=thirdparty%2Fvala.git Fix checking for abstract/virtual methods inside structs Fixes bug 643711. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index a990d9c9e..de000427a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -82,6 +82,7 @@ TESTS = \ objects/bug624594.vala \ objects/bug628639.vala \ objects/bug642809.vala \ + objects/bug643711.vala \ errors/errors.vala \ errors/bug567181.vala \ errors/bug579101.vala \ diff --git a/tests/objects/bug643711.vala b/tests/objects/bug643711.vala new file mode 100644 index 000000000..690c36e84 --- /dev/null +++ b/tests/objects/bug643711.vala @@ -0,0 +1,14 @@ +public abstract class Foo { + public Baz get_struct () { return Baz (); } + public abstract void bar (); +} + +public struct Baz { + Foo foo; + + public void bar () { + foo.bar (); + } +} + +void main () { } diff --git a/vala/valamethod.vala b/vala/valamethod.vala index 5c1b39e6f..cd935a20e 100644 --- a/vala/valamethod.vala +++ b/vala/valamethod.vala @@ -909,9 +909,6 @@ public class Vala.Method : Subroutine { body.check (context); } - context.analyzer.current_source_file = old_source_file; - context.analyzer.current_symbol = old_symbol; - if (context.analyzer.current_struct != null) { if (is_abstract || is_virtual || overrides) { error = true; @@ -926,6 +923,9 @@ public class Vala.Method : Subroutine { return false; } + context.analyzer.current_source_file = old_source_file; + context.analyzer.current_symbol = old_symbol; + if (!external_package && !overrides && !hides && get_hidden_member () != null) { Report.warning (source_reference, "%s hides inherited method `%s'. Use the `new' keyword if hiding was intentional".printf (get_full_name (), get_hidden_member ().get_full_name ())); }