After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 596549 - Problems with templates
Problems with templates
Status: RESOLVED DUPLICATE of bug 667668
Product: vala
Classification: Core
Component: general
0.12.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks: 589521
 
 
Reported: 2009-09-27 23:39 UTC by Maciej (Matthew) Piechotka
Modified: 2012-01-24 10:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-Allow-specialisation-for-properties.patch (6.28 KB, patch)
2011-04-27 07:51 UTC, Maciej (Matthew) Piechotka
none Details | Review

Description Maciej (Matthew) Piechotka 2009-09-27 23:39:57 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).
Comment 1 Maciej (Matthew) Piechotka 2009-12-25 11:35:32 UTC
Present in 0.7.9
Comment 2 Maciej (Matthew) Piechotka 2010-03-28 11:58:21 UTC
Same in Vala 0.7.10.237-b7a17
Comment 3 Luca Bruno 2010-06-02 16:05:17 UTC
Specialization is not yet supported.
Comment 4 Maciej (Matthew) Piechotka 2011-04-25 15:39:47 UTC
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;
	}
}
Comment 5 Maciej (Matthew) Piechotka 2011-04-27 07:51:58 UTC
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.
Comment 6 Luca Bruno 2012-01-18 18:03:05 UTC
Duplicate bug 667668 . Not merging due to different patches.
Comment 7 Luca Bruno 2012-01-18 18:07:50 UTC
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.
Comment 8 Luca Bruno 2012-01-24 10:17:45 UTC
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 ***