2008-03-02 Juerg Billeter <j@bitron.ch>
* vala/valaintegertype.vala: allow implicit conversion from 0 to
enum and flags types
* tests/enums.vala: test conversion from 0 to enum type
svn path=/trunk/; revision=1084
2008-03-02 Jürg Billeter <j@bitron.ch>
+ * vala/valaintegertype.vala: allow implicit conversion from 0 to
+ enum and flags types
+
+ * tests/enums.vala: test conversion from 0 to enum type
+
+2008-03-02 Jürg Billeter <j@bitron.ch>
+
* vapi/glib-2.0.vapi: add bindings for g_get_system_*_dirs
* vala/valacodecontext.vala: use g_get_system_data_dirs to find
stdout.printf (" %d", Foo.VAL5);
}
+ static void test_enums_0_conversion () {
+ Foo foo = 0;
+ }
+
static int main (string[] args) {
stdout.printf ("Enum Test: 1");
bar.run ();
stdout.printf (" 6\n");
-
+
+ test_enums_0_conversion ();
+
return 0;
}
}
return (val >= int_attr.get_integer ("min") && val <= int_attr.get_integer ("max"));
}
}
+ } else if (target_type.data_type is Enum && literal.get_type_name () == "int") {
+ // allow implicit conversion from 0 to enum and flags types
+ if (literal.value.to_int () == 0) {
+ return true;
+ }
}
return base.compatible (target_type, enable_non_null);