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



commit 6eb5f2e434038ff8f4a76ffba9fb773620fa70df
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 f23c42b42..cb5ee3750 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -961,7 +961,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 0a9266cf1..b98568f33 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -123,8 +123,11 @@ public class Vala.Constant : Symbol {
 
                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]