GNOME Bugzilla – Bug 596549
Problems with templates
Last modified: 2012-01-24 10:17:45 UTC
I have certain problems with templates (I'm not sure how to name it). For example such code is allowed: public class TestEntry : Map.Entry<string, string> { public TestEntry (string key, string value) { this._key = key; this.value = value; } public override string key { get {return _key; } } private string _key; public override string value { get; set; } } tests/testmap.vala:516.3-516.30: error: Type and/or accessors of overriding property `MapTests.TestEntry.value' do not match overridden property `Gee.Map.Entry.value'. public override string value { get; set; } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/testmap.vala:516.3-516.30: error: MapTests.TestEntry.value: no suitable property found to override public override string value { get; set; } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/testmap.vala:514.3-514.28: error: Type and/or accessors of overriding property `MapTests.TestEntry.key' do not match overridden property `Gee.Map.Entry.key'. public override string key { get {return _key; } } ^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/testmap.vala:514.3-514.28: error: MapTests.TestEntry.key: no suitable property found to override public override string key { get {return _key; } } ^^^^^^^^^^^^^^^^^^^^^^^^^^ Compilation failed: 4 error(s), 0 warning(s) but: public class TestEntry<K,V> : Map.Entry<K,V> { public TestEntry (K key, V value) { this._key = key; this.value = value; } public override K key { get {return _key; } } private K _key; public override V value { get; set; } } is allowed. Also commented out sections in attachments to Bug 589521 (i.e. Add-SortedMap-interface.patch - now all obsoletes).
Present in 0.7.9
Same in Vala 0.7.10.237-b7a17
Specialization is not yet supported.
The following code is accepted as well: public interface Test<K, V> : GLib.Object { public abstract K? get_k(V v); } public class TestImpl<K, V> : GLib.Object, Test<V, K> { public K? get_k(V v) { return null; } }
Created attachment 186716 [details] [review] 0001-Allow-specialisation-for-properties.patch First patch. Specialisation for methods seems to be supported. In both cases nullable overriding is not permitted.
Duplicate bug 667668 . Not merging due to different patches.
I don't strictly like neither patch at bug 667668 nor this one. I'd like to keep some coding consistency with Method.compatible instead. That is, adding a Property.compatible for checking compatibility with a base property that returns an error string.
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of bug 667668 ***