diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index 44adfcd06829a80d3499950fddf6ec09eeb10678..2448f1ba490474ee2d462bf852f710c2ebb7fffe 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -5277,8 +5277,11 @@ namespace Ttcn { if (initial_value) { char*& init = in_class ? target->temp.constructor_preamble : target->functions.init_comp; - init = initial_value->generate_code_init(init, - initial_value->get_lhs_name().c_str()); + string lhs = initial_value->get_lhs_name(); + if (in_class) { + lhs = string("this->") + lhs; + } + init = initial_value->generate_code_init(init, lhs.c_str()); } else if (clean_up) { // No initial value. target->functions.init_comp = mputprintf(target->functions.init_comp, "%s.clean_up();\n", get_genname().c_str()); @@ -5496,16 +5499,18 @@ namespace Ttcn { if (initial_value) { char*& init = in_class ? target->temp.constructor_preamble : target->functions.init_comp; + string lhs = initial_value->get_lhs_name(); + if (in_class) { + lhs = string("this->") + lhs; + } if (Common::Type::T_SEQOF == initial_value->get_my_governor()->get_typetype() || Common::Type::T_ARRAY == initial_value->get_my_governor()->get_typetype()) { - init = mputprintf(init, "%s.remove_all_permutations();\n", - initial_value->get_lhs_name().c_str()); + init = mputprintf(init, "%s.remove_all_permutations();\n", lhs.c_str()); } - init = initial_value->generate_code_init(init, - initial_value->get_lhs_name().c_str()); + init = initial_value->generate_code_init(init, lhs.c_str()); if (template_restriction!=TR_NONE && gen_restriction_check) init = Template::generate_restriction_check_code(init, - initial_value->get_lhs_name().c_str(), template_restriction); + lhs.c_str(), template_restriction); } else if (clean_up) { // No initial value. // Always reset component variables/variable templates on component // reinitialization. Fix for HM79493. diff --git a/regression_test/oop/oop.ttcn b/regression_test/oop/oop.ttcn index eabee6bdbae2219069204ce4879036ea80994d5c..63601f402adac2a579339c4dfbbcccffb78501d6 100644 --- a/regression_test/oop/oop.ttcn +++ b/regression_test/oop/oop.ttcn @@ -121,8 +121,8 @@ type class SubClass extends BaseClass { type class @final FinalClass extends SubClass { private const integer m_final_const := 1; private template charstring m_final_temp := ? length (1..4); - private var float m_final_var; - private var template octetstring m_final_var_temp; + private var float m_final_var := 1.0; + private var template octetstring m_final_var_temp := ''O; public function @final f(in integer x) return integer { return super.f(x) + m_final_const + 1;