[vala/0.40] vala: Don't require constant initializer in fast-vapi



commit 48e247ff9c537ffd9cc6a30187fcbef0274a0bb7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Nov 14 21:04:42 2019 +0100

    vala: Don't require constant initializer in fast-vapi
    
    Regression of 984c034256de3830d6daa0ab6f5eff108dea09bb
    
    Extend --fast-vapi test by using --use-fast-vapi
    
    See https://github.com/dino/dino/issues/646
    and https://gitlab.gnome.org/GNOME/vala/issues/461

 codegen/valaccodebasemodule.vala | 2 +-
 vala/valaconstant.vala           | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index b8409baca..3f658f0bb 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -944,7 +944,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        return;
                }
 
-               if (!c.external) {
+               if (!c.external || (c.source_type == SourceFileType.FAST && c.value != null)) {
                        generate_type_declaration (c.type_reference, decl_space);
 
                        c.value.emit (this);
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala
index 230c63d5e..1599b267f 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -133,8 +133,11 @@ public class Vala.Constant : Symbol, Lockable {
 
                if (!external) {
                        if (value == null) {
-                               error = true;
-                               Report.error (source_reference, "A const field requires a value to be 
provided");
+                               // constants from fast-vapi files are special
+                               if (source_type != SourceFileType.FAST) {
+                                       error = true;
+                                       Report.error (source_reference, "A const field requires a value to be 
provided");
+                               }
                        } else {
                                value.target_type = type_reference;
 


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