[vala/staging] Slightly improve source_reference for get_dup_func_expression()



commit 453c81d3844ec7ea8ec8dfbcd52346e2c3a24cf7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Aug 6 08:40:31 2021 +0200

    Slightly improve source_reference for get_dup_func_expression()

 codegen/valaccodebasemodule.vala | 4 ++--
 codegen/valagtypemodule.vala     | 2 +-
 vala/valasemanticanalyzer.vala   | 1 +
 vala/valasymbolresolver.vala     | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0c79686de..54fc3e184 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3083,7 +3083,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                }
                        } else {
                                // duplicating non-reference counted objects may cause side-effects (and 
performance issues)
-                               Report.error (source_reference, "duplicating %s instance, use unowned 
variable or explicitly invoke copy method", type.type_symbol.name);
+                               Report.error (source_reference, "duplicating `%s' instance, use unowned 
variable or explicitly invoke copy method", type.type_symbol.name);
                                return new CCodeInvalidExpression();
                        }
 
@@ -4919,7 +4919,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                        arg_map.set (get_param_pos (0.1 * type_param_index + 0.02), get_type_id_expression 
(type_arg, is_chainup));
                        if (requires_copy (type_arg)) {
-                               var dup_func = get_dup_func_expression (type_arg, type_arg.source_reference, 
is_chainup);
+                               var dup_func = get_dup_func_expression (type_arg, type_arg.source_reference 
?? expr.source_reference, is_chainup);
                                if (dup_func == null) {
                                        // type doesn't contain a copy function
                                        expr.error = true;
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 3a6e3f4f1..95e49c56a 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1478,7 +1478,7 @@ public class Vala.GTypeModule : GErrorModule {
 
                                add_generic_accessor_function ("get_%s".printf (get_ccode_copy_function (p)),
                                                               "GBoxedCopyFunc",
-                                                              get_dup_func_expression (p_data_type, null),
+                                                              get_dup_func_expression (p_data_type, 
p_data_type.source_reference),
                                                               p, cl, iface);
 
                                add_generic_accessor_function ("get_%s".printf (get_ccode_destroy_function 
(p)),
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index fa101b6c8..553695568 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -998,6 +998,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        return generic_type;
                }
                actual_type = actual_type.copy ();
+               actual_type.source_reference = generic_type.source_reference;
                actual_type.value_owned = actual_type.value_owned && generic_type.value_owned;
                return actual_type;
        }
diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala
index b5594bfe0..4ac3fbd3c 100644
--- a/vala/valasymbolresolver.vala
+++ b/vala/valasymbolresolver.vala
@@ -427,7 +427,7 @@ public class Vala.SymbolResolver : CodeVisitor {
 
                // still required for vapigen
                if (unresolved_type.unresolved_symbol.name == "void") {
-                       return new VoidType ();
+                       return new VoidType (unresolved_type.source_reference);
                }
 
                var sym = resolve_symbol (unresolved_type.unresolved_symbol);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]