Report.error (used_var.source_reference, "use of possibly unassigned local variable `%s'".printf (used_var.name));
} else {
// parameter
- Report.warning (used_var.source_reference, "use of possibly unassigned parameter `%s'".printf (used_var.name));
+ if (used_var.name == "this") {
+ Report.warning (used_var.source_reference, "possible reference to `this' before chaining up");
+ } else {
+ Report.warning (used_var.source_reference, "use of possibly unassigned parameter `%s'".printf (used_var.name));
+ }
}
continue;
}
Report.error (node.source_reference, "use of possibly unassigned local variable `%s'".printf (var_symbol.name));
} else {
// parameter
- Report.warning (node.source_reference, "use of possibly unassigned parameter `%s'".printf (var_symbol.name));
+ if (var_symbol.name == "this") {
+ Report.warning (node.source_reference, "possible reference to `this' before chaining up");
+ } else {
+ Report.warning (node.source_reference, "use of possibly unassigned parameter `%s'".printf (var_symbol.name));
+ }
}
continue;
}
var param = symbol_reference as Parameter;
if (local != null) {
collection.add (local);
- } else if (param != null && param.direction == ParameterDirection.OUT) {
+ } else if (param != null && (param.direction == ParameterDirection.OUT || (param.name == "this" && param.parent_symbol is CreationMethod && ((CreationMethod) param.parent_symbol).chain_up))) {
collection.add (param);
}
}
var struct_creation_expression = new ObjectCreationExpression ((MemberAccess) call, source_reference);
struct_creation_expression.struct_creation = true;
+ struct_creation_expression.struct_chainup = is_chainup;
foreach (Expression arg in get_argument_list ()) {
struct_creation_expression.add_argument (arg);
}
}
public override void get_defined_variables (Collection<Variable> collection) {
- call.get_defined_variables (collection);
+ if (is_chainup) {
+ var this_parameter = call.symbol_reference as Parameter;
+ if (this_parameter == null) {
+ Symbol sym = (Block) parent_statement.parent_node;
+ do {
+ sym = sym.parent_symbol;
+ } while (sym is Block);
+ this_parameter = ((Method) sym).this_parameter;
+ }
+ collection.add (this_parameter);
+ } else {
+ call.get_defined_variables (collection);
+ }
foreach (Expression arg in argument_list) {
arg.get_defined_variables (collection);
}
public override void get_used_variables (Collection<Variable> collection) {
- call.get_used_variables (collection);
+ if (!is_chainup) {
+ call.get_used_variables (collection);
+ }
foreach (Expression arg in argument_list) {
arg.get_used_variables (collection);
public bool is_yield_expression { get; set; }
public bool struct_creation { get; set; }
+ public bool struct_chainup { get; set; }
private List<Expression> argument_list = new ArrayList<Expression> ();
}
public override void get_defined_variables (Collection<Variable> collection) {
+ if (struct_chainup) {
+ var this_parameter = member_name.inner.symbol_reference as Parameter;
+ if (this_parameter == null) {
+ Symbol sym = (Block) parent_statement.parent_node;
+ do {
+ sym = sym.parent_symbol;
+ } while (sym is Block);
+ this_parameter = ((Method) sym).this_parameter;
+ }
+ collection.add (this_parameter);
+ }
+
foreach (Expression arg in argument_list) {
arg.get_defined_variables (collection);
}