[vala] Fix checking for abstract/virtual methods inside structs



commit 2d3e6cd3b4612d0530f026fc5cc86a38ee1ba24f
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu May 26 20:57:01 2011 +0200

    Fix checking for abstract/virtual methods inside structs
    
    Fixes bug 643711.

 tests/Makefile.am            |    1 +
 tests/objects/bug643711.vala |   14 ++++++++++++++
 vala/valamethod.vala         |    6 +++---
 3 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a990d9c..de00042 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 0000000..690c36e
--- /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 5c1b39e..cd935a2 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 ()));
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]