[vala/staging] class: Perform more thorough compatibility check of inherited properties



commit 69242e1018b110f03ef6e490f308c513368a4f97
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Mar 7 23:12:37 2017 +0100

    class: Perform more thorough compatibility check of inherited properties
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779038

 tests/Makefile.am            |    1 +
 tests/objects/bug779038.test |   19 +++++++++++++++++++
 vala/valaclass.vala          |    6 ++++++
 3 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c8186a8..39735d4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -216,6 +216,7 @@ TESTS = \
        objects/bug615830-2.test \
        objects/bug766739.vala \
        objects/bug778632.vala \
+       objects/bug779038.test \
        objects/bug779219.vala \
        errors/errors.vala \
        errors/bug567181.vala \
diff --git a/tests/objects/bug779038.test b/tests/objects/bug779038.test
new file mode 100644
index 0000000..9ba395b
--- /dev/null
+++ b/tests/objects/bug779038.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+public interface Foo : Object {
+       public abstract string foo { get; set; }
+}
+
+public interface Bar : Object {
+       public abstract string foo { set; }
+}
+
+public class Baz : Object, Foo {
+       public string foo { get; set; }
+}
+
+public class Manam : Baz, Bar {
+}
+
+void main () {
+}
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index b983319..111a18c 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -819,6 +819,12 @@ public class Vala.Class : ObjectTypeSymbol {
                                                                base_class = base_class.base_class;
                                                        }
                                                        if (sym is Property) {
+                                                               var base_prop = (Property) sym;
+                                                               string invalid_match;
+                                                               if (!prop.compatible (base_prop, out 
invalid_match)) {
+                                                                       error = true;
+                                                                       Report.error (source_reference, "Type 
and/or accessors of inherited properties `%s' and `%s' do not match: %s.".printf (prop.get_full_name (), 
base_prop.get_full_name (), invalid_match));
+                                                               }
                                                                // property is used as interface 
implementation, so it is not unused
                                                                sym.version.check (source_reference);
                                                                sym.used = true;


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