]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix regression in method calls that throw errors with Value target type db462e6f919da758fbb2f4e7b3cbbf2897ec852b
authorLuca Bruno <lucabru@src.gnome.org>
Tue, 28 Jan 2014 19:34:47 +0000 (20:34 +0100)
committerLuca Bruno <lucabru@src.gnome.org>
Tue, 28 Jan 2014 19:34:47 +0000 (20:34 +0100)
Related to bug 723009

tests/Makefile.am
tests/methods/bug723009.vala [new file with mode: 0644]
vala/valaassignment.vala
vala/valamethodcall.vala
vala/valaobjectcreationexpression.vala

index f8f882ca19823b2769d82050bf974773d9b32bbe..9c47ec5f28b90d274f63ed1c4ebcbfeb9480c062 100644 (file)
@@ -56,6 +56,7 @@ TESTS = \
        methods/bug653391.vala \
        methods/bug653908.vala \
        methods/bug663210.vala \
+       methods/bug723009.vala \
        methods/generics.vala \
        control-flow/break.vala \
        control-flow/expressions-conditional.vala \
diff --git a/tests/methods/bug723009.vala b/tests/methods/bug723009.vala
new file mode 100644 (file)
index 0000000..d148c34
--- /dev/null
@@ -0,0 +1,9 @@
+public string foo () throws Error {
+       return "foo";
+}
+
+void main () {
+       Value bar;
+       bar = foo ();
+       assert ((string) bar == "foo");
+}
\ No newline at end of file
index 87281ad303f95493f1f936231f250f8c874d6921..7c8599e54288ee1c4767c613651f1f9d9231e98c 100644 (file)
@@ -175,8 +175,8 @@ public class Vala.Assignment : Expression {
                                var sig = (Signal) ma.symbol_reference;
                                right.target_type = new DelegateType (sig.get_delegate (ma.inner.value_type, this));
                        } else {
-                               right.formal_target_type = ma.formal_value_type;
-                               right.target_type = ma.value_type;
+                               right.formal_target_type = ma.formal_value_type.copy ();
+                               right.target_type = ma.value_type.copy ();
                        }
                } else if (left is ElementAccess) {
                        var ea = (ElementAccess) left;
index 44d674e4d447089c5ae0f3023b8d15d11f3ad027..077131cc28060fbdbb732a878b7bf14e198e3204 100644 (file)
@@ -745,17 +745,17 @@ public class Vala.MethodCall : Expression {
                                // store parent_node as we need to replace the expression in the old parent node later on
                                var old_parent_node = parent_node;
 
-                               var local = new LocalVariable (value_type, get_temp_name (), null, source_reference);
+                               var local = new LocalVariable (value_type.copy (), get_temp_name (), null, source_reference);
                                var decl = new DeclarationStatement (local, source_reference);
 
                                insert_statement (context.analyzer.insert_block, decl);
 
+                               var temp_access = SemanticAnalyzer.create_temp_access (local, target_type);
+
                                // don't set initializer earlier as this changes parent_node and parent_statement
                                local.initializer = this;
                                decl.check (context);
 
-                               var temp_access = SemanticAnalyzer.create_temp_access (local, target_type);
-                               temp_access.check (context);
 
                                // move temp variable to insert block to ensure the
                                // variable is in the same block as the declaration
@@ -765,6 +765,7 @@ public class Vala.MethodCall : Expression {
                                context.analyzer.insert_block.add_local_variable (local);
 
                                old_parent_node.replace_expression (this, temp_access);
+                               temp_access.check (context);
                        }
                }
 
index 2a2cda1846a7089d324e77ee6b36a0a191361b50..939b8a65cdd9f8a73758233dda7e7cf4e98a82cc 100644 (file)
@@ -413,17 +413,16 @@ public class Vala.ObjectCreationExpression : Expression {
                                // store parent_node as we need to replace the expression in the old parent node later on
                                var old_parent_node = parent_node;
 
-                               var local = new LocalVariable (value_type, get_temp_name (), null, source_reference);
+                               var local = new LocalVariable (value_type.copy (), get_temp_name (), null, source_reference);
                                var decl = new DeclarationStatement (local, source_reference);
 
                                insert_statement (context.analyzer.insert_block, decl);
 
+                               var temp_access = SemanticAnalyzer.create_temp_access (local, target_type);
                                // don't set initializer earlier as this changes parent_node and parent_statement
                                local.initializer = this;
                                decl.check (context);
 
-                               var temp_access = SemanticAnalyzer.create_temp_access (local, target_type);
-                               temp_access.check (context);
 
                                // move temp variable to insert block to ensure the
                                // variable is in the same block as the declaration
@@ -433,6 +432,7 @@ public class Vala.ObjectCreationExpression : Expression {
                                context.analyzer.insert_block.add_local_variable (local);
 
                                old_parent_node.replace_expression (this, temp_access);
+                               temp_access.check (context);
                        }
                }