diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2010-01-18 00:42:46 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2010-01-18 23:15:09 +0100 |
commit | 950c88b51376cba2b7696d6bd11e564fd2d5a94b (patch) | |
tree | fd268a892ea654c1ed343c26a5fd4920eb666c1c /vala/valapointertype.vala | |
parent | a0eb82a01828f8b6bd867886d734ad7eeeed2a72 (diff) | |
download | vala-950c88b51376cba2b7696d6bd11e564fd2d5a94b.tar.gz |
Do not allow assignment with incompatible pointers
That patch makes type check with pointer more strict.
Fixes bug 574486.
Diffstat (limited to 'vala/valapointertype.vala')
-rw-r--r-- | vala/valapointertype.vala | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala index 76922dcc9..d3203f461 100644 --- a/vala/valapointertype.vala +++ b/vala/valapointertype.vala @@ -62,7 +62,22 @@ public class Vala.PointerType : DataType { } public override bool compatible (DataType target_type) { - if (target_type is PointerType || (target_type.data_type != null && target_type.data_type.get_attribute ("PointerType") != null)) { + if (target_type is PointerType) { + var tt = target_type as PointerType; + + if (tt.base_type is VoidType || base_type is VoidType) { + return true; + } + + /* dereference only if both types are references or not */ + if (base_type.is_reference_type_or_type_parameter () != tt.base_type.is_reference_type_or_type_parameter ()) { + return false; + } + + return base_type.compatible (tt.base_type); + } + + if ((target_type.data_type != null && target_type.data_type.get_attribute ("PointerType") != null)) { return true; } |