From 70a17e1082329f07457793fc8d374a5fdecd43ed Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Tue, 19 May 2020 11:34:59 +0200
Subject: [PATCH] Fixed 'is_identical' function for object class types (bug
 552011)

Change-Id: Ic0bdac1125b4244afcfc0c9b8f53971ad796536f
Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
---
 compiler2/Type.cc                             |  4 +++-
 .../Semantic_Analyser/oop/oop_SE.ttcn         | 22 +++++++++++++------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/compiler2/Type.cc b/compiler2/Type.cc
index ffeee7778..197237808 100644
--- a/compiler2/Type.cc
+++ b/compiler2/Type.cc
@@ -5467,9 +5467,11 @@ namespace Common {
     case T_FUNCTION:
     case T_ALTSTEP:
     case T_TESTCASE:
-    case T_CLASS:
       // user-defined structured types must be identical
       return t1 == t2;
+    case T_CLASS:
+      return t1 == t2 || (t2->typetype == T_CLASS && 
+        t2->u.class_->is_built_in() && t1->u.class_->is_built_in());
     case T_ARRAY:
       // the embedded type and the dimension must be identical in case of arrays
       return t2->typetype == T_ARRAY &&
diff --git a/function_test/Semantic_Analyser/oop/oop_SE.ttcn b/function_test/Semantic_Analyser/oop/oop_SE.ttcn
index c12cc587f..b65e959c9 100644
--- a/function_test/Semantic_Analyser/oop/oop_SE.ttcn
+++ b/function_test/Semantic_Analyser/oop/oop_SE.ttcn
@@ -381,8 +381,16 @@ type class C34 extends C25 { //^In type definition//
   public function f_abs(inout template integer p) return boolean { return false; } //The prototype of method `f_abs' is not identical to that of inherited abstract method `@oop_SE.C25.f_abs'//
 }
 
+type class @abstract C35 {
+  public function @abstract f(in object p) return object;
+}
+
+type class C36 extends C35 {
+  public function f(in object p) return object { return p; }
+}
+
 
-type class C35 {
+type class C37 {
   public const integer c := 3;
   public template charstring t := "";
   public function f1() return Rec { return { 2, "a" }; }
@@ -391,12 +399,12 @@ type class C35 {
 }
 
 function f_left_hand_side() { //^In function definition//
-  var C35 x := C35.create;
-  x.c := 2; //^In variable assignment// //Reference to a variable or template variable was expected instead of constant `@oop_SE.C35.c'//
-  x.t := *; //^In variable assignment// //Reference to a variable or template variable was expected instead of template `@oop_SE.C35.t'//
-  x.f1() := { 3, "b" }; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C35.f1'//
-  x.f1().num := 3; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C35.f1'//
-  x.f2() := "x"; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C35.f2'//
+  var C37 x := C37.create;
+  x.c := 2; //^In variable assignment// //Reference to a variable or template variable was expected instead of constant `@oop_SE.C37.c'//
+  x.t := *; //^In variable assignment// //Reference to a variable or template variable was expected instead of template `@oop_SE.C37.t'//
+  x.f1() := { 3, "b" }; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C37.f1'//
+  x.f1().num := 3; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C37.f1'//
+  x.f2() := "x"; //^In variable assignment// //Reference to a variable or template variable was expected instead of function `@oop_SE.C37.f2'//
 }
 
 
-- 
GitLab