]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
class: Perform more thorough compatibility check of inherited properties e874bb7902cc06f9f6d4427d99ec33e3757304e4
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 7 Mar 2017 22:12:37 +0000 (23:12 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 10 Mar 2017 17:34:40 +0000 (18:34 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=779038

tests/Makefile.am
tests/objects/bug779038-1.test [new file with mode: 0644]
tests/objects/bug779038-2.test [new file with mode: 0644]
tests/objects/bug779038-3.test [new file with mode: 0644]
vala/valaclass.vala

index c8186a820e298f75ad4a05874760eb6d1612c650..4360e5eab1eb7c77e543abe5a4a00678dafed260 100644 (file)
@@ -216,6 +216,9 @@ TESTS = \
        objects/bug615830-2.test \
        objects/bug766739.vala \
        objects/bug778632.vala \
+       objects/bug779038-1.test \
+       objects/bug779038-2.test \
+       objects/bug779038-3.test \
        objects/bug779219.vala \
        errors/errors.vala \
        errors/bug567181.vala \
diff --git a/tests/objects/bug779038-1.test b/tests/objects/bug779038-1.test
new file mode 100644 (file)
index 0000000..9ba395b
--- /dev/null
@@ -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/tests/objects/bug779038-2.test b/tests/objects/bug779038-2.test
new file mode 100644 (file)
index 0000000..7b262f7
--- /dev/null
@@ -0,0 +1,19 @@
+Invalid Code
+
+public interface Foo : Object {
+       public abstract int foo { get; set; }
+}
+
+public interface Bar : Object {
+       public abstract string foo { get; set; }
+}
+
+public class Baz : Object, Foo {
+       public int foo { get; set; }
+}
+
+public class Manam : Baz, Bar {
+}
+
+void main () {
+}
diff --git a/tests/objects/bug779038-3.test b/tests/objects/bug779038-3.test
new file mode 100644 (file)
index 0000000..43e32aa
--- /dev/null
@@ -0,0 +1,19 @@
+Invalid Code
+
+public interface Foo : Object {
+       public abstract string foo { get; construct; }
+}
+
+public interface Bar : Object {
+       public abstract string foo { get; set; }
+}
+
+public class Baz : Object, Foo {
+       public string foo { get; construct; }
+}
+
+public class Manam : Baz, Bar {
+}
+
+void main () {
+}
index b983319beb22e738f6fe9e643308fc22df57a8a7..211c321ddedb770a172f199e401f08f8106aa3a1 100644 (file)
@@ -819,6 +819,13 @@ public class Vala.Class : ObjectTypeSymbol {
                                                                base_class = base_class.base_class;
                                                        }
                                                        if (sym is Property) {
+                                                               var base_prop = (Property) sym;
+                                                               string? invalid_match = null;
+                                                               // No check at all for "new" classified properties, really?
+                                                               if (!base_prop.hides && !base_prop.compatible (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;