diff options
author | Luca Bruno <lucabru@src.gnome.org> | 2014-01-28 20:34:47 +0100 |
---|---|---|
committer | Luca Bruno <lucabru@src.gnome.org> | 2014-01-28 20:34:47 +0100 |
commit | db462e6f919da758fbb2f4e7b3cbbf2897ec852b (patch) | |
tree | f869c5d2c6881a3daae5c95c75d8ec2f822fbdd6 | |
parent | fa7dda0eed0c8d8a2b945c4d848923b1fc102f66 (diff) | |
download | vala-db462e6f919da758fbb2f4e7b3cbbf2897ec852b.tar.gz |
Fix regression in method calls that throw errors with Value target type
Related to bug 723009
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/methods/bug723009.vala | 9 | ||||
-rw-r--r-- | vala/valaassignment.vala | 4 | ||||
-rw-r--r-- | vala/valamethodcall.vala | 7 | ||||
-rw-r--r-- | vala/valaobjectcreationexpression.vala | 6 |
5 files changed, 19 insertions, 8 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index f8f882ca1..9c47ec5f2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..d148c34c8 --- /dev/null +++ b/tests/methods/bug723009.vala @@ -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 diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala index 87281ad30..7c8599e54 100644 --- a/vala/valaassignment.vala +++ b/vala/valaassignment.vala @@ -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; diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala index 44d674e4d..077131cc2 100644 --- a/vala/valamethodcall.vala +++ b/vala/valamethodcall.vala @@ -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); } } diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala index 2a2cda184..939b8a65c 100644 --- a/vala/valaobjectcreationexpression.vala +++ b/vala/valaobjectcreationexpression.vala @@ -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); } } |