Hi all,
First of all, many thanks for a great initiative which has in my opinion
a very bright future!
I am not quit sure on which level invalid type casts should be
monitored, whether it be the vala compiler or the underlaying gobject.
Please view the attached test-case for details.
As I understand, it should be possible to check incompatible types at
compile time and so eliminating further errors.
Regards,
Hans
using GLib;
public class Foo : Object {
public int data { get; construct; }
public Foo (construct int data) {
}
}
public class FalseFoo : Object {
}
public class FooBar : Foo {
public FooBar (int data) {
this.data = data;
}
}
public class App : Object {
static int main (string[] args) {
/* OK implitic cast is good */
Foo foo = new FooBar (1);
/* ERROR Should require explicit cast ? */
FooBar foobar = new Foo (1);
/* OK explicit cast required */
foobar = (FooBar) foo;
/* ERROR Should require explicit cast and fail on compatibility */
Foo foo1 = new FalseFoo ();
/* ERROR should fail on compatible type */
FalseFoo falsefoo = (FalseFoo) foo;
/* Silently accept null cast ? */
foobar = null;
foo = (Foo) foobar;
/* Nullexception */
foo.data = 5;
/* OK foreach implicit upcast */
foreach (Foo item in new FooBar[3]) {
}
/* ERROR should require explicit cast, not allowed in foreach */
foreach (FooBar item in new Foo[3]) {
}
return 0;
}
}
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list