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 578603 - Abilility to subclass compact class with methods only, report error otherwise
Abilility to subclass compact class with methods only, report error otherwise
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Objects
unspecified
Other All
: Normal normal
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-04-10 13:56 UTC by Jaap A. Haitsma
Modified: 2009-07-28 17:33 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jaap A. Haitsma 2009-04-10 13:56:28 UTC
Compiling the following code

// valac sample.vala  --pkg gtk+-2.0 --pkg cairo

using GLib, Cairo;

public class Sample.TestContext : Cairo.Context {

}

public class Sample.App {

	public static void main(string[] args) {		

	}	
}

results in following error

/home/jaap/sample.c:25: error: field ‘parent_instance’ has incomplete type
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

This used to work fine some releases ago
Comment 1 Jaap A. Haitsma 2009-05-14 18:58:39 UTC
Any help I would highly appreciate
Comment 2 Jürg Billeter 2009-05-14 19:17:54 UTC
Cairo is not using GObject, the cairo context is an opaque struct in C. This makes it impossible to support proper subclassing (without writing a library on top of cairo to wrap the native cairo types). The Vala compiler should report an error, though.
Comment 3 Jaap A. Haitsma 2009-05-27 05:01:51 UTC
OK weird thing is that my code worked fine about a year ago
Comment 4 Jürg Billeter 2009-05-27 07:50:39 UTC
If the subclass only adds new methods but no fields, it's certainly possible to implement. We could support that for compact classes if that is sufficient.
Comment 5 Jaap A. Haitsma 2009-06-06 16:50:18 UTC
For me in this case it would be sufficient. I just add some methods to cairo context to make drawing of other objects easier
Comment 6 Jürg Billeter 2009-07-28 17:33:40 UTC
commit fea12020d4f6086fea271f0f1a7832d96fd86169
Author: Jürg Billeter <j@bitron.ch>
Date:   Tue Jul 28 18:50:25 2009 +0200

    Add limited support for derived compact classes
    
    Fixes bug 578603.