[vala/staging: 3/3] memberaccess: Don't resolve base_method/property twice



commit 540154b27e24fc1b5986293bf3f2132ea49dbf31
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Feb 27 16:59:32 2017 +0100

    memberaccess: Don't resolve base_method/property twice
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779219

 tests/Makefile.am            |    1 +
 tests/objects/bug779219.vala |   18 ++++++++++++++++++
 vala/valamemberaccess.vala   |   31 ++++++-------------------------
 3 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2d0b2ed..67baf08 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 0000000..c0c4baa
--- /dev/null
+++ b/tests/objects/bug779219.vala
@@ -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);
+}
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 6911bef..23ca8d6 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -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)


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