diff options
author | Jürg Billeter <j@bitron.ch> | 2011-02-08 20:32:35 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2011-02-08 20:32:35 +0100 |
commit | 7c2fd8a2a9d9503496c96854be95fa7f91ef44a6 (patch) | |
tree | e6e83358020ad751541d851483baafeb6ea9583f /vala/valaconstant.vala | |
parent | 6f12ba028dd6442afa25728e530516af7d8a6f0e (diff) | |
download | vala-7c2fd8a2a9d9503496c96854be95fa7f91ef44a6.tar.gz |
Support translated string constants
Fixes bug 641543.
Diffstat (limited to 'vala/valaconstant.vala')
-rw-r--r-- | vala/valaconstant.vala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala index fab450c17..c9b880cb5 100644 --- a/vala/valaconstant.vala +++ b/vala/valaconstant.vala @@ -203,6 +203,21 @@ public class Vala.Constant : Symbol, Lockable { return false; } + // support translated string constants for efficiency / convenience + // even though the expression is not a compile-time constant + var call = value as MethodCall; + if (call != null) { + var method_type = call.call.value_type as MethodType; + if (method_type != null && method_type.method_symbol.get_full_name () == "GLib._") { + // first argument is string + var literal = call.get_argument_list ().get (0) as StringLiteral; + if (literal != null) { + value = literal; + literal.translate = true; + } + } + } + if (!value.is_constant ()) { error = true; Report.error (value.source_reference, "Value must be constant"); |