From: Rico Tzschichholz Date: Tue, 7 Mar 2017 22:12:37 +0000 (+0100) Subject: class: Perform more thorough compatibility check of inherited properties X-Git-Tag: 0.35.90~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e874bb7902cc06f9f6d4427d99ec33e3757304e4;p=thirdparty%2Fvala.git class: Perform more thorough compatibility check of inherited properties https://bugzilla.gnome.org/show_bug.cgi?id=779038 --- diff --git a/tests/Makefile.am b/tests/Makefile.am index c8186a820..4360e5eab 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..9ba395b63 --- /dev/null +++ b/tests/objects/bug779038-1.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/tests/objects/bug779038-2.test b/tests/objects/bug779038-2.test new file mode 100644 index 000000000..7b262f78b --- /dev/null +++ b/tests/objects/bug779038-2.test @@ -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 index 000000000..43e32aa0b --- /dev/null +++ b/tests/objects/bug779038-3.test @@ -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 () { +} diff --git a/vala/valaclass.vala b/vala/valaclass.vala index b983319be..211c321dd 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -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;