]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
memberaccess: Don't resolve base_method/property twice
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 27 Feb 2017 15:59:32 +0000 (16:59 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 5 Mar 2017 14:45:38 +0000 (15:45 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=779219

tests/Makefile.am
tests/objects/bug779219.vala [new file with mode: 0644]
vala/valamemberaccess.vala

index 2d0b2ed8c8cb0906ce6fc878be45d046838f8d3a..67baf08bd971420f577cfe75690ffff17965cb97 100644 (file)
@@ -214,6 +214,7 @@ TESTS = \
        objects/bug615830-2.test \
        objects/bug766739.vala \
        objects/bug778632.vala \
+       objects/bug779219.vala \
        errors/errors.vala \
        errors/bug567181.vala \
        errors/bug579101.vala \
diff --git a/tests/objects/bug779219.vala b/tests/objects/bug779219.vala
new file mode 100644 (file)
index 0000000..c0c4baa
--- /dev/null
@@ -0,0 +1,18 @@
+interface IFoo : GLib.Object {
+       public abstract int foo { get; }
+}
+
+abstract class Foo : GLib.Object, IFoo {
+       public abstract int foo { get; }
+}
+
+class Bar : Foo {
+       public override int foo { get { return 42; } }
+       public Bar () {
+       }
+}
+
+void main () {
+       var bar = new Bar ();
+       assert (bar.foo == 42);
+}
index 6911bef65476f5b5c2e33933ecd0f98ed2919082..23ca8d68bf5f68901f6b6a6f897ad9a25d472e1b 100644 (file)
@@ -823,37 +823,18 @@ public class Vala.MemberAccess : Expression {
                        }
 
                        if (symbol_reference is Method) {
+                               var method = (Method) symbol_reference;
                                if (target_type != null) {
                                        value_type.value_owned = target_type.value_owned;
                                }
-
-                               Method base_method;
-                               if (m.base_method != null) {
-                                       base_method = m.base_method;
-                               } else if (m.base_interface_method != null) {
-                                       base_method = m.base_interface_method;
-                               } else {
-                                       base_method = m;
-                               }
-
-                               if (instance && base_method.parent_symbol is TypeSymbol) {
-                                       inner.target_type = SemanticAnalyzer.get_data_type_for_symbol ((TypeSymbol) base_method.parent_symbol);
-                                       inner.target_type.value_owned = base_method.this_parameter.variable_type.value_owned;
+                               if (instance && method.parent_symbol is TypeSymbol) {
+                                       inner.target_type = SemanticAnalyzer.get_data_type_for_symbol ((TypeSymbol) method.parent_symbol);
+                                       inner.target_type.value_owned = method.this_parameter.variable_type.value_owned;
                                }
                        } else if (symbol_reference is Property) {
                                var prop = (Property) symbol_reference;
-
-                               Property base_property;
-                               if (prop.base_property != null) {
-                                       base_property = prop.base_property;
-                               } else if (prop.base_interface_property != null) {
-                                       base_property = prop.base_interface_property;
-                               } else {
-                                       base_property = prop;
-                               }
-
-                               if (instance && base_property.parent_symbol != null) {
-                                       inner.target_type = SemanticAnalyzer.get_data_type_for_symbol ((TypeSymbol) base_property.parent_symbol);
+                               if (instance && prop.parent_symbol != null) {
+                                       inner.target_type = SemanticAnalyzer.get_data_type_for_symbol ((TypeSymbol) prop.parent_symbol);
                                }
                        } else if ((symbol_reference is Field
                                    || symbol_reference is Signal)