diff options
author | Luca Bruno <lucabru@src.gnome.org> | 2011-08-07 12:44:41 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2018-10-23 18:45:45 +0200 |
commit | 6395a2efe8f166fe8b2595fc2ba08dc4bcc69216 (patch) | |
tree | 330e9fd04c476190b76ccc8710ca1d9dd8573fa8 /vala/valaobjectcreationexpression.vala | |
parent | 6c44fc72635e0a55f57bb9db526c4d83ddd551df (diff) | |
download | vala-6395a2efe8f166fe8b2595fc2ba08dc4bcc69216.tar.gz |
Collect error_types on demand to allow transformations
Diffstat (limited to 'vala/valaobjectcreationexpression.vala')
-rw-r--r-- | vala/valaobjectcreationexpression.vala | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala index 8bef09b25..4b609aee7 100644 --- a/vala/valaobjectcreationexpression.vala +++ b/vala/valaobjectcreationexpression.vala @@ -246,8 +246,6 @@ public class Vala.ObjectCreationExpression : Expression { value_type = type_reference.copy (); value_type.value_owned = true; - bool may_throw = false; - int given_num_type_args = type_reference.get_type_arguments ().size; int expected_num_type_args = 0; @@ -423,16 +421,6 @@ public class Vala.ObjectCreationExpression : Expression { } context.analyzer.check_arguments (this, new MethodType (m), m.get_parameters (), args); - - foreach (DataType error_type in m.get_error_types ()) { - may_throw = true; - - // ensure we can trace back which expression may throw errors of this type - var call_error_type = error_type.copy (); - call_error_type.source_reference = source_reference; - - add_error_type (call_error_type); - } } else if (type_reference is ErrorType) { if (type_reference != null) { type_reference.check (context); @@ -484,7 +472,7 @@ public class Vala.ObjectCreationExpression : Expression { context.analyzer.visit_member_initializer (init, type_reference); } - if (may_throw) { + if (tree_can_fail) { if (parent_node is LocalVariable || parent_node is ExpressionStatement) { // simple statements, no side effects after method call } else if (!(context.analyzer.current_symbol is Block)) { @@ -519,6 +507,16 @@ public class Vala.ObjectCreationExpression : Expression { return !error; } + public override void get_error_types (Collection<DataType> collection, SourceReference? source_reference = null) { + if (symbol_reference is Method) { + if (source_reference == null) { + source_reference = this.source_reference; + } + var m = (Method) symbol_reference; + m.get_error_types (collection, source_reference); + } + } + public override void emit (CodeGenerator codegen) { foreach (Expression arg in argument_list) { arg.emit (codegen); |