]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix checking for abstract/virtual methods inside structs
authorLuca Bruno <lucabru@src.gnome.org>
Thu, 26 May 2011 18:57:01 +0000 (20:57 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Thu, 26 May 2011 19:02:10 +0000 (21:02 +0200)
Fixes bug 643711.

tests/Makefile.am
tests/objects/bug643711.vala [new file with mode: 0644]
vala/valamethod.vala

index a990d9c9e90da4a418cacd2d37d301d37b533ecc..de000427add5d4b2c2b1877cda7cdd5abf83edca 100644 (file)
@@ -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 (file)
index 0000000..690c36e
--- /dev/null
@@ -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 () { }
index 5c1b39e6fda5c44e0b9012eadcf12f5e11701c64..cd935a20ed8787b6b4fd3277ceebfbde1a34b0f0 100644 (file)
@@ -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 ()));
                }