diff --git a/compiler2/ttcn3/Ttcnstuff.cc b/compiler2/ttcn3/Ttcnstuff.cc index 34a1547f33216170aeef3cbc7494ac90afc44251..033d2450dd8c86dc973280c4d5777b3fe83da4bb 100644 --- a/compiler2/ttcn3/Ttcnstuff.cc +++ b/compiler2/ttcn3/Ttcnstuff.cc @@ -3472,6 +3472,17 @@ namespace Ttcn { local_def->error("Cannot override final method `%s'", base_def->get_fullname().c_str()); } + else if (local_func->is_identical(base_func)) { + if (base_func->get_visibility() == PUBLIC && local_func->get_visibility() != PUBLIC) { + local_def->error("Public methods can be only overridden by public methods `%s'", + local_id.get_dispname().c_str()); + } + else if (base_func->get_visibility() == NOCHANGE && + (local_func->get_visibility() != PUBLIC || local_func->get_visibility() != NOCHANGE)) { + local_def->error("Protected methods can be only overridden by " + "public or protected methods `%s'", local_id.get_dispname().c_str()); + } + } break; } default: local_def->error("%s shadows inherited member `%s'",