diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc index 6cd2d4a0169eb5cdade6c2e09fddd652b3e2bedf..8df5fb1a4fa9e240d44b04990452215dca15f3d7 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 41505dbf5f17b6786c8a96986db993831b9a9a9d..fe51b1147b166ac5ef000c6a4c438bd65e123ac6 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 85945297a78fe2cb05e2210c6495af4e46c479e0..d3494c3cfa26b2dd83b6f4d84d10245ed042265b 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.// }