From ff3c932dd25e72b7449fa06520439f4246fa46b6 Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Thu, 11 Mar 2021 11:12:45 +0100
Subject: [PATCH] OOP: functions and external functions now count as identical
 when checking overriding methods in classes (Bug 568899)

Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I6bb317a5a9361024c0fb4da304126acf43bc80e0
---
 compiler2/ttcn3/AST_ttcn3.cc                    | 16 ++++++++++++----
 function_test/Semantic_Analyser/oop/oop_SE.ttcn |  5 +++++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc
index 8c86d4ac6..0bbdd6475 100644
--- a/compiler2/ttcn3/AST_ttcn3.cc
+++ b/compiler2/ttcn3/AST_ttcn3.cc
@@ -6809,11 +6809,19 @@ namespace Ttcn {
   
   bool Def_Function_Base::is_identical(Def_Function_Base* p_other)
   {
-    if (asstype != p_other->get_asstype()) {
-      return false;
+    Common::Assignment::asstype_t asstype2 = p_other->get_asstype();
+    if (asstype != asstype2) {
+      if ((asstype == Common::Assignment::A_FUNCTION && asstype2 != Common::Assignment::A_EXT_FUNCTION) ||
+          (asstype == Common::Assignment::A_EXT_FUNCTION && asstype2 != Common::Assignment::A_FUNCTION) ||
+          (asstype == Common::Assignment::A_FUNCTION_RVAL && asstype2 != Common::Assignment::A_EXT_FUNCTION_RVAL) ||
+          (asstype == Common::Assignment::A_EXT_FUNCTION_RVAL && asstype2 != Common::Assignment::A_FUNCTION_RVAL) ||
+          (asstype == Common::Assignment::A_FUNCTION_RTEMP && asstype2 != Common::Assignment::A_EXT_FUNCTION_RTEMP) ||
+          (asstype == Common::Assignment::A_EXT_FUNCTION_RTEMP && asstype2 != Common::Assignment::A_FUNCTION_RTEMP)) {
+        return false;
+      }
     }
-    else if (return_type != NULL &&
-             !p_other->return_type->is_identical(return_type)) {
+    if (return_type != NULL &&
+        !p_other->return_type->is_identical(return_type)) {
       return false;
     }
     FormalParList* other_fp_list = p_other->get_FormalParList();
diff --git a/function_test/Semantic_Analyser/oop/oop_SE.ttcn b/function_test/Semantic_Analyser/oop/oop_SE.ttcn
index d3494c3cf..b5a49e641 100644
--- a/function_test/Semantic_Analyser/oop/oop_SE.ttcn
+++ b/function_test/Semantic_Analyser/oop/oop_SE.ttcn
@@ -482,6 +482,11 @@ type class C48 extends C47 { //^In type definition//
   function m4() { } //Cannot override final method `@oop_SE.C47.m4'//
 }
 
+type class C49 extends C40 {
+  function f1(in integer p) return octetstring { return int2oct(p, 2); }
+  function f2() { }
+}
+
 
 function f_of_operator() { //^In function definition//
   var C0 x := C0.create;
-- 
GitLab