static bool method_chain(pass_opt_t* opt, ast_t* ast) { if(!method_application(opt, ast, false)) return false; // We check the receiver cap now instead of in method_application because // we need to know whether the receiver was recovered. ast_t* lhs = ast_childidx(ast, 2); ast_t* r_type = method_receiver_type(lhs); if(ast_id(lhs) == TK_FUNCHAIN) { bool recovered; if(!check_receiver_cap(opt, ast, &recovered)) return false; if(!check_nonsendable_recover(opt, ast)) return false; ast_t* f_type = ast_type(lhs); token_id f_cap = ast_id(ast_child(f_type)); ast_t* c_type = chain_type(r_type, f_cap, recovered); ast_settype(ast, c_type); } else { ast_settype(ast, r_type); } return true; }
static bool method_chain(pass_opt_t* opt, ast_t* ast) { if(!method_application(opt, ast, false)) return false; AST_GET_CHILDREN(ast, positional, namedargs, question, lhs); ast_t* type = ast_type(lhs); if(ast_id(ast_child(type)) == TK_AT) { ast_error(opt->check.errors, ast, "a bare method cannot be chained"); return false; } // We check the receiver cap now instead of in method_application because // we need to know whether the receiver was recovered. ast_t* r_type = method_receiver_type(lhs); if(ast_id(lhs) == TK_FUNCHAIN) { bool recovered; if(!check_receiver_cap(opt, ast, &recovered)) return false; if(!check_nonsendable_recover(opt, ast)) return false; ast_t* f_type = ast_type(lhs); token_id f_cap = ast_id(ast_child(f_type)); ast_t* c_type = chain_type(r_type, f_cap, recovered); ast_settype(ast, c_type); } else { ast_settype(ast, r_type); } return true; }