From 339d8d049986007798e4306821896122c14ce059 Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Wed, 13 Jan 2021 16:52:43 +0100
Subject: [PATCH] OOP: aliases for class types are no longer allowed (bug
 568745, 568899)

Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I3ef81abf7e118384f0edf0cf29f281a86065a6c4
---
 compiler2/Type_chk.cc                                    | 3 +++
 .../OOP_tests/negative_tests/50101_classes.script        | 2 +-
 function_test/Semantic_Analyser/oop/oop_SE.ttcn          | 9 +++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc
index 6cd2d4a01..8df5fb1a4 100644
--- a/compiler2/Type_chk.cc
+++ b/compiler2/Type_chk.cc
@@ -3634,6 +3634,9 @@ void Type::chk_refd()
   checked=true;
   ReferenceChain refch(this, "While checking referenced type");
   Type* t_last = get_type_refd_last(&refch);
+  if (ownertype == OT_TYPE_DEF && t_last->typetype == T_CLASS) {
+    error("Subtyping is not allowed for class type `%s'", t_last->get_typename().c_str());
+  }
   u.ref.component_internal = t_last->is_component_internal();
 }
 
diff --git a/conformance_test/OOP_tests/negative_tests/50101_classes.script b/conformance_test/OOP_tests/negative_tests/50101_classes.script
index 41505dbf5..fe51b1147 100644
--- a/conformance_test/OOP_tests/negative_tests/50101_classes.script
+++ b/conformance_test/OOP_tests/negative_tests/50101_classes.script
@@ -1166,7 +1166,7 @@ module NegSem_50101_top_level_005  "TTCN-3:2018 Object-Oriented"{
 <END_MODULE>
 
 <RESULT COUNT>
-error: 
+error: Subtyping is not allowed for class type
 <END_RESULT>
 
 <END_TC>
diff --git a/function_test/Semantic_Analyser/oop/oop_SE.ttcn b/function_test/Semantic_Analyser/oop/oop_SE.ttcn
index 85945297a..d3494c3cf 100644
--- a/function_test/Semantic_Analyser/oop/oop_SE.ttcn
+++ b/function_test/Semantic_Analyser/oop/oop_SE.ttcn
@@ -536,6 +536,15 @@ function f_start_comp() { //^In function definition//
 }
 
 
+type C47 C47_alias; //^In type definition// //Subtyping is not allowed for class type//
+type C47_alias C47_alias_alias; //^In type definition// //Subtyping is not allowed for class type//
+
+function f_aliases() {
+  var C47_alias x1 := C47_alias.create(1);
+  var C47_alias_alias x2 := C47_alias_alias.create(2);
+}
+
+
 control { //^In control part//
   var C11 x := C11.create; //^In variable definition// //A definition without `runs on' clause cannot create a value of class type `@oop_SE.C11', which runs on component type `@oop_SE.CT_RunsOn'// //Cannot create value of class type `@oop_SE.C11', which has an `mtc' clause, in the control part.// //Cannot create value of class type `@oop_SE.C11', which has a `system' clause, in the control part.//
 }
-- 
GitLab