]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Check compatibility of generic type arguments
authorJürg Billeter <j@bitron.ch>
Wed, 3 Jun 2009 09:05:29 +0000 (11:05 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 3 Jun 2009 09:05:29 +0000 (11:05 +0200)
Fixes bug 520952.

vala/valadatatype.vala
vapigen/valavapicheck.vala

index 8150fb9c4bb46102adbf027c68149d32b721b985..97d681f9d21554854817117f8d66151202372326 100644 (file)
@@ -328,6 +328,23 @@ public abstract class Vala.DataType : CodeNode {
                }
 
                if (data_type == target_type.data_type) {
+                       // check compatibility of generic type arguments
+                       if (type_argument_list != null
+                           && type_argument_list.size > 0
+                           && type_argument_list.size == target_type.get_type_arguments ().size) {
+                               for (int i = 0; i < type_argument_list.size; i++) {
+                                       var type_arg = type_argument_list[i];
+                                       var target_type_arg = target_type.get_type_arguments ()[i];
+                                       // mutable generic types require type argument equality,
+                                       // not just one way compatibility
+                                       // as we do not currently have immutable generic container types,
+                                       // the additional check would be very inconvenient, so we
+                                       // skip the additional check for now
+                                       if (!type_arg.compatible (target_type_arg)) {
+                                               return false;
+                                       }
+                               }
+                       }
                        return true;
                }
 
index 50ecd9252fad25a6bb7b4ae5b5f2b8aa2092d270..6122a0121474b9c7e994e1a3fb43f43c99160d9f 100644 (file)
@@ -84,7 +84,7 @@ class Vala.VAPICheck : Object {
 
                                case IdlNodeTypeId.FUNCTION:
                                        parse_members (((IdlNodeFunction) node).symbol,
-                                                                  ((IdlNodeFunction) node).parameters);
+                                                                  (List<IdlNode>) ((IdlNodeFunction) node).parameters);
                                        break;
 
                                case IdlNodeTypeId.BOXED: