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 538405 - Implementing generic interface with concrete type doesn't work
Implementing generic interface with concrete type doesn't work
Status: RESOLVED DUPLICATE of bug 511286
Product: vala
Classification: Core
Component: Code Generator
0.3.x
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-06-15 08:15 UTC by Frederik Zipp
Modified: 2008-07-30 21:04 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Frederik Zipp 2008-06-15 08:15:04 UTC
Please describe the problem:
It is not possible to implement a generic interface with a concrete type.

Steps to reproduce:
public interface MyInterface<G> {
    public abstract void method_a (G param);
    public abstract G method_b ();
}

public class MyIterator : GLib.Object, MyInterface<int> {

    public void method_a (int param) {
        // do something
    }

    public int method_b () {
        return 0;
    }
}


Actual results:
testcase.vala:8.5-8.24: error: overriding method `MyIterator.method_a' is incompatible with base method `MyInterface.method_a': incompatible type of parameter 1.
    public void method_a (int param) {
    ^^^^^^^^^^^^^^^^^^^^
testcase.vala:12.5-12.23: error: overriding method `MyIterator.method_b' is incompatible with base method `MyInterface.method_b': incompatible return type.
    public int method_b () {
    ^^^^^^^^^^^^^^^^^^^
Compilation failed: 2 error(s), 0 warning(s)


Expected results:
The generic parts of the parent interface should be fixated to the specified type, in this case 'int'.

Does this happen every time?


Other information:
Comment 1 Jürg Billeter 2008-07-30 21:04:07 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 511286 ***