diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index e5d3569b29b367ea7e45063b885afab7d8ff4c33..c0022fc51120c8a52baf156a52e0e8629dc2983d 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -1039,6 +1039,9 @@ namespace Ttcn { if (!Ref_base::has_single_expr()) { return false; } + if (reftype == REF_THIS && id == NULL) { + return false; + } if (parlist != NULL) { Common::Assignment* ass = get_refd_assignment(); const FormalParList* fplist = (ass != NULL) ? ass->get_FormalParList() : NULL; @@ -1124,8 +1127,10 @@ namespace Ttcn { expr->expr = mputstr(expr->expr, "this->"); } else { // no 'id' means it's just a 'this' reference - expr->expr = mputprintf(expr->expr, "%s(this)", - ass->get_Type()->get_genname_value(my_scope).c_str()); + string tmp_id = my_scope->get_scope_mod_gen()->get_temporary_id(); + expr->preamble = mputprintf(expr->preamble, "%s %s(this);\n", + ass->get_Type()->get_genname_value(my_scope).c_str(), tmp_id.c_str()); + expr->expr = mputprintf(expr->expr, "%s", tmp_id.c_str()); return; } } diff --git a/regression_test/oop/oop.ttcn b/regression_test/oop/oop.ttcn index 4b3f6272d8597698549b7077ed13f059148dc895..381a005c9f5f30f962dd8471cab4ccc6c008ea9f 100644 --- a/regression_test/oop/oop.ttcn +++ b/regression_test/oop/oop.ttcn @@ -33,6 +33,10 @@ type union Uni { charstring cs } +function f_this_as_param(object p) { + log(p); +} + type class BaseClass runs on CT mtc CT system CT { public const integer m_const := 1; private const IntList m_const2 := { 1, 2, 3 }; @@ -96,6 +100,7 @@ type class BaseClass runs on CT mtc CT system CT { if (this != v_ref2) { setverdict(fail, "inequality failed"); } + f_this_as_param(this); } } finally {