]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Don't mark simple-type out-parameters with '?' as nullable
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 11 Dec 2017 08:08:25 +0000 (09:08 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 11 Dec 2017 09:09:24 +0000 (10:09 +0100)
Using '?' on simple-types has a different meaning in vala and would create
a boxed-type which is not compatible with the original type.

vala/valagirparser.vala

index d51d469d1918bfc91bff0eba23c6033084b0c0d7..d169cd7b77c4de3d38d75e218fef82f44170a5a2 100644 (file)
@@ -3694,6 +3694,24 @@ public class Vala.GirParser : CodeVisitor {
                                }
                        }
                }
+
+               // Do not mark out-parameters as nullable if they are simple-types,
+               // since it would result in a boxed-type in vala
+               foreach (ParameterInfo info in parameters) {
+                       var type = info.param.variable_type;
+                       if (info.param.direction == ParameterDirection.OUT && type.nullable) {
+                               Struct? st = null;
+                               if (type is UnresolvedType) {
+                                       st = resolve_symbol (node.parent, ((UnresolvedType) type).unresolved_symbol) as Struct;
+                               } else if (type is ValueType) {
+                                       st = type.data_type as Struct;
+                               }
+                               if (st != null && st.is_simple_type ()) {
+                                       type.nullable = false;
+                               }
+                       }
+               }
+
                if (parameters.size > 1) {
                        ParameterInfo last_param = parameters[parameters.size-1];
                        if (last_param.param.ellipsis) {