From e89b6841b8c85afe3dfd98d6a5dbf70932fa5931 Mon Sep 17 00:00:00 2001
From: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
Date: Thu, 5 Jan 2017 09:20:59 +0100
Subject: [PATCH] xsd2ttcn: implemented type aliases when restriction/extension
 has no real effect (artf640920)

Change-Id: I26d3378f497d30d42bf7e2bd3594beea21234b30
Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
---
 ..._org_nillable_in_nillable_extension_e.ttcn |  75 ++++
 .../name_conversion_extension_attrib_e.ttcn   |  24 +-
 ...www_example_org_complextype_aliases_e.ttcn | 294 +++++++++++++++
 .../www_example_org_namespaceas_e.ttcn        |  20 +-
 .../www_example_org_simpletype_aliases_e.ttcn | 343 ++++++++++++++++++
 .../XML/XmlWorkflow/src/xmlTest.prj           |   6 +-
 .../XmlWorkflow/src/xmlTest_Testcases.ttcn    |  32 ++
 .../XmlWorkflow/xsd/complextype_aliases.xsd   | 208 +++++++++++
 .../xsd/name_conversion_extension_attrib.xsd  |  27 +-
 .../xsd/nillable_in_nillable_extension.xsd    |  79 ++++
 .../XmlWorkflow/xsd/simpletype_aliases.xsd    | 282 ++++++++++++++
 xsdconvert/ComplexType.cc                     | 209 +++++++++--
 xsdconvert/ComplexType.hh                     |   5 +-
 xsdconvert/SimpleType.cc                      |  30 +-
 xsdconvert/SimpleType.hh                      |  17 +-
 15 files changed, 1592 insertions(+), 59 deletions(-)
 create mode 100644 regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn
 create mode 100644 regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_simpletype_aliases_e.ttcn
 create mode 100644 regression_test/XML/XmlWorkflow/xsd/complextype_aliases.xsd
 create mode 100644 regression_test/XML/XmlWorkflow/xsd/simpletype_aliases.xsd

diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_example_org_nillable_in_nillable_extension_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_example_org_nillable_in_nillable_extension_e.ttcn
index 89f3f9195..4cb778954 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_example_org_nillable_in_nillable_extension_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_example_org_nillable_in_nillable_extension_e.ttcn
@@ -64,6 +64,81 @@ type record NillableInRecord
 	XSD.Boolean allow_do_not,
 	record {
 		XSD.Integer phoneNumber optional,
+		SeqNillable content optional
+	} seqNillableExtended optional
+}
+with {
+  variant "element";
+  variant (allow_do_not) "name as 'allow-do-not'";
+  //variant (allow_do_not) "text 'true' as '1'";
+  //variant (allow_do_not) "text 'false' as '0'";
+  variant (seqNillableExtended) "name as capitalized";
+  variant (seqNillableExtended) "useNil";
+  variant (seqNillableExtended.phoneNumber) "name as capitalized";
+  variant (seqNillableExtended.phoneNumber) "attribute";
+};
+
+
+type record NillableInRecordAlias
+{
+	XSD.Boolean allow_do_not,
+	record {
+		SeqNillable content optional
+	} seqNillableExtended optional
+}
+with {
+  variant "element";
+  variant (allow_do_not) "name as 'allow-do-not'";
+  //variant (allow_do_not) "text 'true' as '1'";
+  //variant (allow_do_not) "text 'false' as '0'";
+  variant (seqNillableExtended) "name as capitalized";
+  variant (seqNillableExtended) "useNil";
+};
+
+
+type record NillableInRecordNotAlias
+{
+	XSD.Boolean allow_do_not,
+	record {
+		record {
+			XSD.Integer number optional
+		} content optional
+	} seqNillableExtended optional
+}
+with {
+  variant "element";
+  variant (allow_do_not) "name as 'allow-do-not'";
+  //variant (allow_do_not) "text 'true' as '1'";
+  //variant (allow_do_not) "text 'false' as '0'";
+  variant (seqNillableExtended) "name as capitalized";
+  variant (seqNillableExtended) "useNil";
+  variant (seqNillableExtended.content.number) "name as capitalized";
+};
+
+
+type record SeqNillable2
+{
+	XSD.Integer phoneNumber optional,
+	XSD.Integer number optional,
+	record length(0 .. 32) of record {
+		XSD.Integer content optional
+	} nillableNumber_list
+}
+with {
+  variant (phoneNumber) "name as capitalized";
+  variant (phoneNumber) "attribute";
+  variant (number) "name as capitalized";
+  variant (nillableNumber_list) "untagged";
+  variant (nillableNumber_list[-]) "name as 'NillableNumber'";
+  variant (nillableNumber_list[-]) "useNil";
+};
+
+
+type record NillableInRecordRestriction
+{
+	XSD.Boolean allow_do_not,
+	record {
+		XSD.Integer phoneNumber,
 		record {
 			XSD.Integer number optional,
 			record length(0 .. 32) of record {
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/name_conversion_extension_attrib_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/name_conversion_extension_attrib_e.ttcn
index cbfafde7c..ffc54dedb 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/name_conversion_extension_attrib_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/name_conversion_extension_attrib_e.ttcn
@@ -56,17 +56,37 @@ with {
 
 
 type record Ol_actions_type
+{
+	XSD.Integer do_not_disturb,
+	record {
+		Ol_name_type announcement_name,
+		Ol_name_type content optional
+	} play_segmented_announcement
+}
+with {
+  variant "name as 'Ol-actions-type'";
+  variant "element";
+  variant (do_not_disturb) "name as 'do-not-disturb'";
+  variant (play_segmented_announcement) "name as 'play-segmented-announcement'";
+  variant (play_segmented_announcement) "useNil";
+  variant (play_segmented_announcement.announcement_name) "name as 'announcement-name'";
+  variant (play_segmented_announcement.announcement_name) "attribute";
+};
+
+
+type record Ol_actions_type2
 {
 	XSD.Integer do_not_disturb,
 	record {
 		Ol_name_type announcement_name,
 		record {
-			XSD.Integer allow_true_action
+			XSD.Integer allow_true_action,
+			XSD.String elem
 		} content optional
 	} play_segmented_announcement
 }
 with {
-  variant "name as 'Ol-actions-type'";
+  variant "name as 'Ol-actions-type2'";
   variant "element";
   variant (do_not_disturb) "name as 'do-not-disturb'";
   variant (play_segmented_announcement) "name as 'play-segmented-announcement'";
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn
new file mode 100644
index 000000000..e26d85495
--- /dev/null
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn
@@ -0,0 +1,294 @@
+/******************************************************************************
+* Copyright (c) 2000-2016 Ericsson Telecom AB
+*
+* XSD to TTCN-3 Translator
+*
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+*   Szabo, Bence Janos
+*
+******************************************************************************/
+//
+//  File:          www_example_org_complextype_aliases.ttcn
+//  Description:
+//  References:
+//  Rev:
+//  Prodnr:
+//  Updated:       Wed Jun 17 13:42:09 2015
+//  Contact:       http://ttcn.ericsson.se
+//
+////////////////////////////////////////////////////////////////////////////////
+//	Generated from file(s):
+//	- complextype_aliases.xsd
+//			/* xml version = "1.0" encoding = "UTF-8" */
+//			/* targetnamespace = "www.example.org/complextype/aliases" */
+////////////////////////////////////////////////////////////////////////////////
+//     Modification header(s):
+//-----------------------------------------------------------------------------
+//  Modified by:
+//  Modification date:
+//  Description:
+//  Modification contact:
+//------------------------------------------------------------------------------
+////////////////////////////////////////////////////////////////////////////////
+
+
+module www_example_org_complextype_aliases {
+
+
+import from XSD all;
+
+
+/* Theese types needed to force the nameconversion */
+
+
+type XSD.AnyType ComplexTypeExtensionNotAlias
+with {
+  variant "name as 'ComplexTypeExtensionNotAlias_'";
+  variant "element";
+};
+
+
+type XSD.AnyType ComplexTypeRestrictionAlias
+with {
+  variant "name as 'ComplexTypeRestrictionAlias_'";
+  variant "element";
+};
+
+
+type record ComplexType
+{
+	XSD.Integer elem
+};
+
+
+type ComplexType ComplexTypeExtensionAlias;
+
+
+/* Not alias because extended with attr attribute */
+
+
+type record ComplexTypeExtensionNotAlias_1
+{
+	XSD.String attr optional,
+	XSD.Integer elem
+}
+with {
+  variant "name as 'ComplexTypeExtensionNotAlias'";
+  variant (attr) "attribute";
+};
+
+
+type ComplexTypeExtensionNotAlias_1 ComplexTypeExtensionAlias2;
+
+
+/* Not alias because extended with elem1 element */
+
+
+type record ComplexTypeExtensionNotAlias2
+{
+	XSD.String attr optional,
+	XSD.Integer elem,
+	XSD.Integer elem1
+}
+with {
+  variant (attr) "attribute";
+};
+
+
+type ComplexTypeExtensionNotAlias2 ComplexTypeExtensionAlias3;
+
+
+/* Not alias because extended with optional sequence */
+
+
+type record ComplexTypeExtensionNotAlias3
+{
+	XSD.String attr optional,
+	XSD.Integer elem,
+	XSD.Integer elem1,
+	record {
+		XSD.Integer elem2
+	} sequence optional
+}
+with {
+  variant (attr) "attribute";
+  variant (sequence) "untagged";
+};
+
+
+type ComplexTypeExtensionNotAlias3 ComplexTypeExtensionAlias4;
+
+
+/* Resitrictions */
+
+
+type record ComplexType2
+{
+	XSD.String attr optional,
+	record length(0 .. 2) of record {
+		XSD.Integer elem optional,
+		record length(1 .. 2) of XSD.Integer elem1_list
+	} sequence_list
+}
+with {
+  variant (attr) "attribute";
+  variant (sequence_list) "untagged";
+  variant (sequence_list[-]) "untagged";
+  variant (sequence_list[-].elem1_list) "untagged";
+  variant (sequence_list[-].elem1_list[-]) "name as 'elem1'";
+};
+
+
+type ComplexType2 ComplexTypeRestrictionAlias_1
+with {
+  variant "name as 'ComplexTypeRestrictionAlias'";
+};
+
+
+type ComplexTypeRestrictionAlias_1 ComplexTypeRestrictionAlias2;
+
+
+/* Not alias because the minOccurs of the sequence is restricted to 1 */
+
+
+type record ComplexTypeRestrictionNotAlias
+{
+	XSD.String attr optional,
+	record length(1 .. 2) of record {
+		XSD.Integer elem optional,
+		record length(1 .. 2) of XSD.Integer elem1_list
+	} sequence_list
+}
+with {
+  variant (attr) "attribute";
+  variant (sequence_list) "untagged";
+  variant (sequence_list[-]) "untagged";
+  variant (sequence_list[-].elem1_list) "untagged";
+  variant (sequence_list[-].elem1_list[-]) "name as 'elem1'";
+};
+
+
+/* Not alias because the minOccurs of the elem element is restricted to 1 */
+
+
+type record ComplexTypeRestrictionNotAlias2
+{
+	XSD.String attr optional,
+	record length(0 .. 2) of record {
+		XSD.Integer elem,
+		record length(1 .. 2) of XSD.Integer elem1_list
+	} sequence_list
+}
+with {
+  variant (attr) "attribute";
+  variant (sequence_list) "untagged";
+  variant (sequence_list[-]) "untagged";
+  variant (sequence_list[-].elem1_list) "untagged";
+  variant (sequence_list[-].elem1_list[-]) "name as 'elem1'";
+};
+
+
+/* Not alias because of the elem element is removed */
+
+
+type record ComplexTypeRestrictionNotAlias3
+{
+	XSD.String attr optional,
+	record length(0 .. 2) of record {
+		record length(1 .. 2) of XSD.Integer elem1_list
+	} sequence_list
+}
+with {
+  variant (attr) "attribute";
+  variant (sequence_list) "untagged";
+  variant (sequence_list[-]) "untagged";
+  variant (sequence_list[-].elem1_list) "untagged";
+  variant (sequence_list[-].elem1_list[-]) "name as 'elem1'";
+};
+
+
+/* Not alias because of the attr attribute is required */
+
+
+type record ComplexTypeRestrictionNotAlias4
+{
+	XSD.String attr,
+	record length(0 .. 2) of record {
+		XSD.Integer elem optional,
+		record length(1 .. 2) of XSD.Integer elem1_list
+	} sequence_list
+}
+with {
+  variant (attr) "attribute";
+  variant (sequence_list) "untagged";
+  variant (sequence_list[-]) "untagged";
+  variant (sequence_list[-].elem1_list) "untagged";
+  variant (sequence_list[-].elem1_list[-]) "name as 'elem1'";
+};
+
+
+/* Alias attribute is not mentioned */
+
+
+type ComplexTypeRestrictionAlias2 ComplexTypeRestrictionAlias3;
+
+
+/* Not alias because of the elem element's fixed value is 2 */
+
+
+type record ComplexTypeRestrictionNotAlias5
+{
+	XSD.String attr optional,
+	record length(0 .. 2) of record {
+		XSD.Integer elem (2) optional,
+		record length(1 .. 2) of XSD.Integer elem1_list
+	} sequence_list
+}
+with {
+  variant (attr) "attribute";
+  variant (sequence_list) "untagged";
+  variant (sequence_list[-]) "untagged";
+  variant (sequence_list[-].elem) "defaultForEmpty as '2'";
+  variant (sequence_list[-].elem1_list) "untagged";
+  variant (sequence_list[-].elem1_list[-]) "name as 'elem1'";
+};
+
+
+/* Not alias because of the elem1 element removed and the elem element is not optional */
+
+
+type record ComplexTypeRestrictionNotAlias6
+{
+	XSD.String attr optional,
+	record length(0 .. 2) of record {
+		XSD.Integer elem (2)
+	} sequence_list
+}
+with {
+  variant (attr) "attribute";
+  variant (sequence_list) "untagged";
+  variant (sequence_list[-]) "untagged";
+  variant (sequence_list[-].elem) "defaultForEmpty as '2'";
+};
+
+
+/* Not alias because everything is removed */
+
+
+type record ComplexTypeRestrictionNotAlias7
+{
+
+};
+
+
+}
+with {
+  encode "XML";
+  variant "namespace as 'www.example.org/complextype/aliases' prefix 'this'";
+  variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
+}
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_namespaceas_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_namespaceas_e.ttcn
index dd79d52ec..aacf4ed31 100644
--- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_namespaceas_e.ttcn
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_namespaceas_e.ttcn
@@ -66,26 +66,18 @@ with {
 
 type record OtherType
 {
-	XSD.Integer billingAccountNumber,
-	record {
-		Foobar base
-	} something,
-	record {
-		Bar base
-	} something2,
-	record {
-		XSD.String something optional
-	} something3,
+	Foobar billingAccountNumber,
+	Foobar something,
+	Bar something2,
+	Bar something3,
 	record {
 		XSD.String something
 	} something4
 }
 with {
   variant (billingAccountNumber) "namespace as 'www.example.org/imported2' prefix 'other'";
-  variant (something.base) "namespace as 'www.example.org/imported2' prefix 'other'";
-  variant (something.base) "untagged";
-  variant (something2.base) "namespace as 'www.example.org/imported2' prefix 'other'";
-  variant (something2.base) "untagged";
+  variant (something) "namespace as 'www.example.org/imported2' prefix 'other'";
+  variant (something2) "namespace as 'www.example.org/imported2' prefix 'other'";
 };
 
 
diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_simpletype_aliases_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_simpletype_aliases_e.ttcn
new file mode 100644
index 000000000..50f538848
--- /dev/null
+++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_simpletype_aliases_e.ttcn
@@ -0,0 +1,343 @@
+/******************************************************************************
+* Copyright (c) 2000-2016 Ericsson Telecom AB
+*
+* XSD to TTCN-3 Translator
+*
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+*   Szabo, Bence Janos
+*
+******************************************************************************/
+//
+//  File:          www_example_org_simpletype_aliases.ttcn
+//  Description:
+//  References:
+//  Rev:
+//  Prodnr:
+//  Updated:       Wed Jun 17 13:42:09 2015
+//  Contact:       http://ttcn.ericsson.se
+//
+////////////////////////////////////////////////////////////////////////////////
+//	Generated from file(s):
+//	- simpletype_aliases.xsd
+//			/* xml version = "1.0" encoding = "UTF-8" */
+//			/* targetnamespace = "www.example.org/simpletype/aliases" */
+////////////////////////////////////////////////////////////////////////////////
+//     Modification header(s):
+//-----------------------------------------------------------------------------
+//  Modified by:
+//  Modification date:
+//  Description:
+//  Modification contact:
+//------------------------------------------------------------------------------
+////////////////////////////////////////////////////////////////////////////////
+
+
+module www_example_org_simpletype_aliases {
+
+
+import from XSD all;
+
+
+/* Theese types needed to force the nameconversion */
+
+
+type XSD.AnyType Length
+with {
+  variant "name as 'Length_'";
+  variant "element";
+};
+
+
+type XSD.AnyType ComplexSimpleNotAlias
+with {
+  variant "name as 'ComplexSimpleNotAlias_'";
+  variant "element";
+};
+
+
+type XSD.AnyType ComplexSimpleAlias3
+with {
+  variant "name as 'ComplexSimpleAlias3_'";
+  variant "element";
+};
+
+
+type XSD.AnyType ComplexSimpleAlias4
+with {
+  variant "name as 'ComplexSimpleAlias4_'";
+  variant "element";
+};
+
+
+type enumerated Enumeration
+{
+	a,
+	b
+};
+
+
+/* Not alias because the restriction element is not empty */
+
+
+type enumerated EnumerationNotAlias
+{
+	a,
+	b
+};
+
+
+type Enumeration EnumerationAlias2;
+
+
+type EnumerationAlias2 EnumerationAlias3;
+
+
+/* Not alias because it is restricted to 'a' */
+
+
+type enumerated EnumerationNotAlias2
+{
+	a
+};
+
+
+type XSD.String Pattern (pattern "abcd");
+
+
+/* Not alias because the restriction element is not empty */
+
+
+type XSD.String PatternNotAlias (pattern "abcd");
+
+
+type Pattern PatternAlias;
+
+
+type PatternAlias PatternAlias2;
+
+
+/* Not alias because it is restricted to 'abc' */
+
+
+type XSD.String PatternNotAlias2 (pattern "abc");
+
+
+type XSD.String Length_1 length(4 .. infinity)
+with {
+  variant "name as 'Length'";
+};
+
+
+/* Not alias because the restriction element is not empty */
+
+
+type XSD.String LengthNotAlias length(4 .. infinity);
+
+
+type Length_1 LengthAlias;
+
+
+type LengthAlias LengthAlias2;
+
+
+/* Not alias because the minLength is restricted to 5 */
+
+
+type XSD.String LengthNotAlias2 length(5 .. infinity);
+
+
+type XSD.Integer Value (5 .. infinity);
+
+
+/* Not alias because the restriction element is not empty */
+
+
+type XSD.Integer ValueNotAlias (5 .. infinity);
+
+
+type Value ValueAlias;
+
+
+type ValueAlias ValueAlias2;
+
+
+/* Not alias because the minInclusiveness is restricted to 6 */
+
+
+type XSD.Integer ValueNotAlias2 (6 .. infinity);
+
+
+type XSD.String WhiteSpace
+with {
+  variant "whiteSpace preserve";
+};
+
+
+/* Not alias because the restriction element is not empty */
+
+
+type XSD.String WhiteSpaceNotAlias
+with {
+  variant "whiteSpace preserve";
+};
+
+
+type WhiteSpace WhiteSpaceAlias;
+
+
+type WhiteSpaceAlias WhiteSpaceAlias2;
+
+
+/* Not alias because the whiteSpace is restricted to replace */
+
+
+type XSD.String WhiteSpaceNotAlias2
+with {
+  variant "whiteSpace replace";
+};
+
+
+type Length_1 ComplexSimpleAlias;
+
+
+/* Not alias because extended with attributes */
+
+
+type record ComplexSimpleNotAlias_1
+{
+	XSD.String attrgroup1 optional,
+	XSD.String attrgroup2 optional,
+	XSD.String base length(4 .. infinity)
+}
+with {
+  variant "name as 'ComplexSimpleNotAlias'";
+  variant (attrgroup1) "attribute";
+  variant (attrgroup2) "attribute";
+  variant (base) "untagged";
+};
+
+
+type LengthAlias2 ComplexSimpleAlias2;
+
+
+/* Not alias because extended with attribute */
+
+
+type record ComplexSimpleNotAlias2
+{
+	XSD.String attr optional,
+	XSD.String base length(4 .. infinity)
+}
+with {
+  variant (attr) "attribute";
+  variant (base) "untagged";
+};
+
+
+type ComplexSimpleNotAlias_1 ComplexSimpleAlias3_1
+with {
+  variant "name as 'ComplexSimpleAlias3'";
+};
+
+
+/* Not alias because extended with attribute */
+
+
+type record ComplexSimpleNotAlias3
+{
+	XSD.String attr optional,
+	XSD.String attrgroup1 optional,
+	XSD.String attrgroup2 optional,
+	XSD.String base length(4 .. infinity)
+}
+with {
+  variant (attr) "attribute";
+  variant (attrgroup1) "attribute";
+  variant (attrgroup2) "attribute";
+  variant (base) "untagged";
+};
+
+
+type ComplexSimpleNotAlias3 ComplexSimpleAlias4_1
+with {
+  variant "name as 'ComplexSimpleAlias4'";
+};
+
+
+/* Not alias because extended with attribute */
+
+
+type record ComplexSimpleNotAlias4
+{
+	XSD.String attr optional,
+	XSD.String attr2 optional,
+	XSD.String attrgroup1 optional,
+	XSD.String attrgroup2 optional,
+	XSD.String base length(4 .. infinity)
+}
+with {
+  variant (attr) "attribute";
+  variant (attr2) "attribute";
+  variant (attrgroup1) "attribute";
+  variant (attrgroup2) "attribute";
+  variant (base) "untagged";
+};
+
+
+type ComplexSimpleNotAlias4 ComplexSimpleRestrictionAlias;
+
+
+type ComplexSimpleRestrictionAlias ComplexSimpleRestrictionAlias2;
+
+
+/* Not alias because the minLength of the base is restricted to 5 */
+
+
+type record ComplexSimpleRestrictionNotAlias
+{
+	XSD.String attr optional,
+	XSD.String attr2 optional,
+	XSD.String attrgroup1 optional,
+	XSD.String attrgroup2 optional,
+	XSD.String base length(5 .. infinity)
+}
+with {
+  variant (attr) "attribute";
+  variant (attr2) "attribute";
+  variant (attrgroup1) "attribute";
+  variant (attrgroup2) "attribute";
+  variant (base) "untagged";
+};
+
+
+/* Not alias because the attr attribute is required */
+
+
+type record ComplexSimpleRestrictionNotAlias2
+{
+	XSD.String attr,
+	XSD.String attr2 optional,
+	XSD.String attrgroup1 optional,
+	XSD.String attrgroup2 optional,
+	XSD.String base length(4 .. infinity)
+}
+with {
+  variant (attr) "attribute";
+  variant (attr2) "attribute";
+  variant (attrgroup1) "attribute";
+  variant (attrgroup2) "attribute";
+  variant (base) "untagged";
+};
+
+
+}
+with {
+  encode "XML";
+  variant "namespace as 'www.example.org/simpletype/aliases' prefix 'this'";
+  variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
+}
diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest.prj b/regression_test/XML/XmlWorkflow/src/xmlTest.prj
index 43684fcef..83253140c 100644
--- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj
+++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj
@@ -168,7 +168,9 @@
 		<File path="../xsd/www_example_org_pref1.xsd" />
 		<File path="../xsd/www_example_org_pref2.xsd" />
 		<File path="../xsd/www_example_org_pref3.xsd" />
-        <File path="../xsd/listMinMaxOccurs.xsd" />
+		<File path="../xsd/listMinMaxOccurs.xsd" />
+		<File path="../xsd/simpletype_aliases.xsd" />
+		<File path="../xsd/complextype_aliases.xsd" />
             </File_Group>
             <File_Group name="XmlTest_xsds" >
                 <File path="../XmlTest_xsds/XmlTest_boolean.xsd" />
@@ -409,6 +411,8 @@
 	        <File path="../XmlTest_expectedTtcns/www_example_org_pref2_e.ttcn" />
 	        <File path="../XmlTest_expectedTtcns/www_example_org_pref3_e.ttcn" />
             <File path="../XmlTest_expectedTtcns/http_www_example_org_list_minmaxoccurs_e.ttcn" />
+            <File path="../XmlTest_expectedTtcns/www_example_org_simpletype_aliases_e.ttcn" />
+            <File path="../XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn" />
             </File_Group>
             <File_Group name="XmlTest_src" >
                 <File path="xmlTest_Shell.ttcn" />
diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn
index cf904d69e..4911d6230 100644
--- a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn
+++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn
@@ -2383,6 +2383,34 @@ group Elements{
 
   }//tc_
 
+  //========================================================
+  // Alias tests
+  //========================================================
+
+  testcase tc_simpletype_aliases() runs on xmlTest_CT {
+
+    f_shellCommandWithVerdict(xsd2ttcn_command & " simpletype_aliases.xsd","",c_shell_successWithoutWarningAndError)
+
+    if(getverdict==pass) {
+      f_compareFiles(
+        "www_example_org_simpletype_aliases_e.ttcn",
+        "www_example_org_simpletype_aliases.ttcn", c_numOfDiff);
+    }
+
+  }//tc_
+
+  testcase tc_complextype_aliases() runs on xmlTest_CT {
+
+    f_shellCommandWithVerdict(xsd2ttcn_command & " complextype_aliases.xsd","",c_shell_successWithoutWarningAndError)
+
+    if(getverdict==pass) {
+      f_compareFiles(
+        "www_example_org_complextype_aliases_e.ttcn",
+        "www_example_org_complextype_aliases.ttcn", c_numOfDiff);
+    }
+
+  }//tc_
+
 
 
   //========================================================
@@ -2736,6 +2764,10 @@ control {
   execute(tc_type_substitution_complex_cascade());
   execute(tc_type_substitution_simple_cascade());
 
+  //===aliases===
+  execute(tc_simpletype_aliases());
+  execute(tc_complextype_aliases());
+
 
 
   execute(tc_element_nameInheritance_conv());
diff --git a/regression_test/XML/XmlWorkflow/xsd/complextype_aliases.xsd b/regression_test/XML/XmlWorkflow/xsd/complextype_aliases.xsd
new file mode 100644
index 000000000..9d197701a
--- /dev/null
+++ b/regression_test/XML/XmlWorkflow/xsd/complextype_aliases.xsd
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:this="www.example.org/complextype/aliases"
+ targetNamespace="www.example.org/complextype/aliases">
+
+
+<!-- Theese types needed to force the nameconversion -->
+<xsd:element name="ComplexTypeExtensionNotAlias_"/>
+<xsd:element name="ComplexTypeRestrictionAlias_"/>
+
+
+<xsd:complexType name="ComplexType">
+	<xsd:sequence>
+		<xsd:element name="elem" type="xsd:integer"/>
+	</xsd:sequence>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexTypeExtensionAlias">
+	<xsd:complexContent>
+		<xsd:extension base="this:ComplexType"/>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because extended with attr attribute -->
+<xsd:complexType name="ComplexTypeExtensionNotAlias">
+	<xsd:complexContent>
+		<xsd:extension base="this:ComplexTypeExtensionAlias">
+			<xsd:attribute name="attr" type="xsd:string"/>
+		</xsd:extension>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexTypeExtensionAlias2">
+	<xsd:complexContent>
+		<xsd:extension base="this:ComplexTypeExtensionNotAlias"/>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because extended with elem1 element -->
+<xsd:complexType name="ComplexTypeExtensionNotAlias2">
+	<xsd:complexContent>
+		<xsd:extension base="this:ComplexTypeExtensionAlias2">
+			<xsd:sequence>
+				<xsd:element name="elem1" type="xsd:integer"/>
+			</xsd:sequence>
+		</xsd:extension>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexTypeExtensionAlias3">
+	<xsd:complexContent>
+		<xsd:extension base="this:ComplexTypeExtensionNotAlias2"/>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because extended with optional sequence -->
+<xsd:complexType name="ComplexTypeExtensionNotAlias3">
+	<xsd:complexContent>
+		<xsd:extension base="this:ComplexTypeExtensionAlias3">
+			<xsd:sequence minOccurs="0">
+				<xsd:element name="elem2" type="xsd:integer"/>
+			</xsd:sequence>
+		</xsd:extension>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexTypeExtensionAlias4">
+	<xsd:complexContent>
+		<xsd:extension base="this:ComplexTypeExtensionNotAlias3"/>
+	</xsd:complexContent>
+</xsd:complexType>
+
+
+
+<!-- Resitrictions -->
+
+<xsd:complexType name="ComplexType2">
+	<xsd:sequence minOccurs="0" maxOccurs="2">
+		<xsd:element name="elem" type="xsd:integer" minOccurs="0"/>
+		<xsd:element name="elem1" type="xsd:integer" maxOccurs="2"/>
+	</xsd:sequence>
+	<xsd:attribute name="attr" type="xsd:string" use="optional"/>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexTypeRestrictionAlias">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexType2">
+			<xsd:sequence minOccurs="0" maxOccurs="2">
+				<xsd:element name="elem" type="xsd:integer" minOccurs="0"/>
+				<xsd:element name="elem1" type="xsd:integer" maxOccurs="2"/>
+			</xsd:sequence>
+			<xsd:attribute name="attr" type="xsd:string" use="optional"/>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexTypeRestrictionAlias2">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexTypeRestrictionAlias">
+			<xsd:sequence minOccurs="0" maxOccurs="2">
+				<xsd:element name="elem" type="xsd:integer" minOccurs="0"/>
+				<xsd:element name="elem1" type="xsd:integer" maxOccurs="2"/>
+			</xsd:sequence>
+			<xsd:attribute name="attr" type="xsd:string" use="optional"/>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because the minOccurs of the sequence is restricted to 1 -->
+<xsd:complexType name="ComplexTypeRestrictionNotAlias">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexTypeRestrictionAlias2">
+			<xsd:sequence minOccurs="1" maxOccurs="2">
+				<xsd:element name="elem" type="xsd:integer" minOccurs="0"/>
+				<xsd:element name="elem1" type="xsd:integer" maxOccurs="2"/>
+			</xsd:sequence>
+			<xsd:attribute name="attr" type="xsd:string" use="optional"/>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because the minOccurs of the elem element is restricted to 1 -->
+<xsd:complexType name="ComplexTypeRestrictionNotAlias2">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexTypeRestrictionAlias2">
+			<xsd:sequence minOccurs="0" maxOccurs="2">
+				<xsd:element name="elem" type="xsd:integer" minOccurs="1"/>
+				<xsd:element name="elem1" type="xsd:integer" maxOccurs="2"/>
+			</xsd:sequence>
+			<xsd:attribute name="attr" type="xsd:string" use="optional"/>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because of the elem element is removed -->
+<xsd:complexType name="ComplexTypeRestrictionNotAlias3">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexTypeRestrictionAlias2">
+			<xsd:sequence minOccurs="0" maxOccurs="2">
+				<xsd:element name="elem1" type="xsd:integer" maxOccurs="2"/>
+			</xsd:sequence>
+			<xsd:attribute name="attr" type="xsd:string" use="optional"/>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because of the attr attribute is required -->
+<xsd:complexType name="ComplexTypeRestrictionNotAlias4">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexTypeRestrictionAlias2">
+			<xsd:sequence minOccurs="0" maxOccurs="2">
+				<xsd:element name="elem" type="xsd:integer" minOccurs="0"/>
+				<xsd:element name="elem1" type="xsd:integer" maxOccurs="2"/>
+			</xsd:sequence>
+			<xsd:attribute name="attr" type="xsd:string" use="required"/>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Alias attribute is not mentioned -->
+<xsd:complexType name="ComplexTypeRestrictionAlias3">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexTypeRestrictionAlias2">
+			<xsd:sequence minOccurs="0" maxOccurs="2">
+				<xsd:element name="elem" type="xsd:integer" minOccurs="0"/>
+				<xsd:element name="elem1" type="xsd:integer" maxOccurs="2"/>
+			</xsd:sequence>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because of the elem element's fixed value is 2 -->
+<xsd:complexType name="ComplexTypeRestrictionNotAlias5">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexTypeRestrictionAlias2">
+			<xsd:sequence minOccurs="0" maxOccurs="2">
+				<xsd:element name="elem" type="xsd:integer" minOccurs="0" fixed="2"/>
+				<xsd:element name="elem1" type="xsd:integer" maxOccurs="2"/>
+			</xsd:sequence>
+			<xsd:attribute name="attr" type="xsd:string" use="optional"/>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because of the elem1 element removed and the elem element is not optional -->
+<xsd:complexType name="ComplexTypeRestrictionNotAlias6">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexTypeRestrictionNotAlias5">
+			<xsd:sequence minOccurs="0" maxOccurs="2">
+				<xsd:element name="elem" type="xsd:integer" minOccurs="1" fixed="2"/>
+			</xsd:sequence>
+			<xsd:attribute name="attr" type="xsd:string" use="optional"/>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+<!-- Not alias because everything is removed -->
+<xsd:complexType name="ComplexTypeRestrictionNotAlias7">
+	<xsd:complexContent>
+		<xsd:restriction base="this:ComplexTypeRestrictionNotAlias6">
+			<xsd:attribute name="attr" type="xsd:string" use="prohibited"/>
+		</xsd:restriction>
+	</xsd:complexContent>
+</xsd:complexType>
+
+
+</xsd:schema>
diff --git a/regression_test/XML/XmlWorkflow/xsd/name_conversion_extension_attrib.xsd b/regression_test/XML/XmlWorkflow/xsd/name_conversion_extension_attrib.xsd
index 45dfea72d..bf75f849c 100644
--- a/regression_test/XML/XmlWorkflow/xsd/name_conversion_extension_attrib.xsd
+++ b/regression_test/XML/XmlWorkflow/xsd/name_conversion_extension_attrib.xsd
@@ -6,6 +6,7 @@
   xmlns:ns="name_conversion_extension_attrib" 
 	 elementFormDefault="qualified"
 	 attributeFormDefault="unqualified">
+	 
 <xs:element name="Ol-name-type">
 	<xs:complexType>
 		<xs:sequence>
@@ -14,16 +15,38 @@
 		</xs:sequence>
 	</xs:complexType>
 </xs:element>
+
 <xs:element name="Ol-actions-type">
 	<xs:complexType>
 		<xs:sequence>
-                        <xs:element name="do-not-disturb" type="xs:integer">
+			<xs:element name="do-not-disturb" type="xs:integer">
 			</xs:element>
 			<xs:element name="play-segmented-announcement" nillable="true">
 					<xs:complexType>
 						<xs:complexContent>
 							<xs:extension base="ns:Ol-name-type">
-                       						<xs:attribute name="announcement-name" type="ns:Ol-name-type" use="required"/>
+								<xs:attribute name="announcement-name" type="ns:Ol-name-type" use="required"/>
+							</xs:extension>
+						</xs:complexContent>
+					</xs:complexType>
+			</xs:element>
+		</xs:sequence>
+	</xs:complexType>
+</xs:element>
+
+<xs:element name="Ol-actions-type2">
+	<xs:complexType>
+		<xs:sequence>
+			<xs:element name="do-not-disturb" type="xs:integer">
+			</xs:element>
+			<xs:element name="play-segmented-announcement" nillable="true">
+					<xs:complexType>
+						<xs:complexContent>
+							<xs:extension base="ns:Ol-name-type">
+								<xs:sequence>
+									<xs:element name="elem" type="xs:string"/>
+								</xs:sequence>
+								<xs:attribute name="announcement-name" type="ns:Ol-name-type" use="required"/>
 							</xs:extension>
 						</xs:complexContent>
 					</xs:complexType>
diff --git a/regression_test/XML/XmlWorkflow/xsd/nillable_in_nillable_extension.xsd b/regression_test/XML/XmlWorkflow/xsd/nillable_in_nillable_extension.xsd
index 955c1c31a..5b1e1061a 100644
--- a/regression_test/XML/XmlWorkflow/xsd/nillable_in_nillable_extension.xsd
+++ b/regression_test/XML/XmlWorkflow/xsd/nillable_in_nillable_extension.xsd
@@ -33,4 +33,83 @@ attributeFormDefault="unqualified">
 	</xs:complexType>
 </xs:element>
 
+<xs:element name="NillableInRecordAlias">
+	<xs:complexType>
+		<xs:sequence>
+			<xs:element name="allow-do-not" type="xs:boolean">
+			</xs:element>
+			<xs:element name="SeqNillableExtended" minOccurs="0" maxOccurs="1" nillable="true">
+				<xs:complexType>
+					<xs:complexContent>
+						<xs:restriction base="ns12:SeqNillable">
+							<xs:sequence>
+								<xs:element name="Number" type="xs:integer" minOccurs="0">
+								</xs:element>
+								<xs:element name="NillableNumber" type="xs:integer" minOccurs="0" maxOccurs="32" nillable="true">
+								</xs:element>
+							</xs:sequence>
+						</xs:restriction>
+					</xs:complexContent>
+				</xs:complexType>
+			</xs:element>
+		</xs:sequence>
+	</xs:complexType>
+</xs:element>
+
+<xs:element name="NillableInRecordNotAlias">
+	<xs:complexType>
+		<xs:sequence>
+			<xs:element name="allow-do-not" type="xs:boolean">
+			</xs:element>
+			<xs:element name="SeqNillableExtended" minOccurs="0" maxOccurs="1" nillable="true">
+				<xs:complexType>
+					<xs:complexContent>
+						<xs:restriction base="ns12:SeqNillable">
+							<xs:sequence>
+								<xs:element name="Number" type="xs:integer" minOccurs="0">
+								</xs:element>
+							</xs:sequence>
+						</xs:restriction>
+					</xs:complexContent>
+				</xs:complexType>
+			</xs:element>
+		</xs:sequence>
+	</xs:complexType>
+</xs:element>
+
+<xs:complexType name="SeqNillable2">
+	<xs:sequence>
+		<xs:element name="Number" type="xs:integer" minOccurs="0">
+		</xs:element>
+		<xs:element name="NillableNumber" type="xs:integer" minOccurs="0" maxOccurs="32" nillable="true">
+		</xs:element>
+	</xs:sequence>
+	<xs:attribute name="PhoneNumber" type="xs:integer"/>
+</xs:complexType>
+
+<xs:element name="NillableInRecordRestriction">
+	<xs:complexType>
+		<xs:sequence>
+			<xs:element name="allow-do-not" type="xs:boolean">
+			</xs:element>
+			<xs:element name="SeqNillableExtended" minOccurs="0" maxOccurs="1" nillable="true">
+				<xs:complexType>
+					<xs:complexContent>
+						<xs:restriction base="ns12:SeqNillable2">
+							<xs:sequence>
+								<xs:element name="Number" type="xs:integer" minOccurs="0">
+								</xs:element>
+								<xs:element name="NillableNumber" type="xs:integer" minOccurs="0" maxOccurs="32" nillable="true">
+								</xs:element>
+							</xs:sequence>
+							<xs:attribute name="PhoneNumber" type="xs:integer" use="required">
+							</xs:attribute>
+						</xs:restriction>
+					</xs:complexContent>
+				</xs:complexType>
+			</xs:element>
+		</xs:sequence>
+	</xs:complexType>
+</xs:element>
+
 </xs:schema>
diff --git a/regression_test/XML/XmlWorkflow/xsd/simpletype_aliases.xsd b/regression_test/XML/XmlWorkflow/xsd/simpletype_aliases.xsd
new file mode 100644
index 000000000..7d8db45fe
--- /dev/null
+++ b/regression_test/XML/XmlWorkflow/xsd/simpletype_aliases.xsd
@@ -0,0 +1,282 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:this="www.example.org/simpletype/aliases"
+ targetNamespace="www.example.org/simpletype/aliases">
+
+
+<!-- Theese types needed to force the nameconversion -->
+<xsd:element name="Length_"/>
+<xsd:element name="ComplexSimpleNotAlias_"/>
+<xsd:element name="ComplexSimpleAlias3_"/>
+<xsd:element name="ComplexSimpleAlias4_"/>
+
+
+<xsd:simpleType name="Enumeration">
+	<xsd:restriction base="xsd:string">
+		<enumeration value="a"/>
+		<enumeration value="b"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because the restriction element is not empty -->
+<xsd:simpleType name="EnumerationNotAlias">
+	<xsd:restriction base="this:Enumeration">
+		<enumeration value="a"/>
+		<enumeration value="b"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="EnumerationAlias2">
+	<xsd:restriction base="this:Enumeration">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="EnumerationAlias3">
+	<xsd:restriction base="this:EnumerationAlias2">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because it is restricted to 'a' -->
+<xsd:simpleType name="EnumerationNotAlias2">
+	<xsd:restriction base="this:EnumerationAlias2">
+		<enumeration value="a"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+
+
+<xsd:simpleType name="Pattern">
+	<xsd:restriction base="xsd:string">
+		<pattern value="abcd"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because the restriction element is not empty -->
+<xsd:simpleType name="PatternNotAlias">
+	<xsd:restriction base="this:Pattern">
+		<pattern value="abcd"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="PatternAlias">
+	<xsd:restriction base="this:Pattern">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="PatternAlias2">
+	<xsd:restriction base="this:PatternAlias">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because it is restricted to 'abc' -->
+<xsd:simpleType name="PatternNotAlias2">
+	<xsd:restriction base="this:PatternAlias2">
+		<pattern value="abc"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+
+
+<xsd:simpleType name="Length">
+	<xsd:restriction base="xsd:string">
+		<minLength value="4"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because the restriction element is not empty -->
+<xsd:simpleType name="LengthNotAlias">
+	<xsd:restriction base="this:Length">
+		<minLength value="4"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="LengthAlias">
+	<xsd:restriction base="this:Length">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="LengthAlias2">
+	<xsd:restriction base="this:LengthAlias">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because the minLength is restricted to 5 -->
+<xsd:simpleType name="LengthNotAlias2">
+	<xsd:restriction base="this:LengthAlias2">
+		<minLength value="5"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+
+
+<xsd:simpleType name="Value">
+	<xsd:restriction base="xsd:integer">
+		<minInclusive value="5"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because the restriction element is not empty -->
+<xsd:simpleType name="ValueNotAlias">
+	<xsd:restriction base="this:Value">
+		<minInclusive value="5"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="ValueAlias">
+	<xsd:restriction base="this:Value">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="ValueAlias2">
+	<xsd:restriction base="this:ValueAlias">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because the minInclusiveness is restricted to 6 -->
+<xsd:simpleType name="ValueNotAlias2">
+	<xsd:restriction base="this:ValueAlias2">
+		<minInclusive value="6"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+
+
+<xsd:simpleType name="WhiteSpace">
+	<xsd:restriction base="xsd:string">
+		<xsd:whiteSpace value="preserve"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because the restriction element is not empty -->
+<xsd:simpleType name="WhiteSpaceNotAlias">
+	<xsd:restriction base="this:WhiteSpace">
+		<xsd:whiteSpace value="preserve"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="WhiteSpaceAlias">
+	<xsd:restriction base="this:WhiteSpace">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<xsd:simpleType name="WhiteSpaceAlias2">
+	<xsd:restriction base="this:WhiteSpaceAlias">
+	</xsd:restriction>
+</xsd:simpleType>
+
+<!-- Not alias because the whiteSpace is restricted to replace -->
+<xsd:simpleType name="WhiteSpaceNotAlias2">
+	<xsd:restriction base="this:WhiteSpaceAlias2">
+		<xsd:whiteSpace value="replace"/>
+	</xsd:restriction>
+</xsd:simpleType>
+
+
+<xsd:complexType name="ComplexSimpleAlias">
+	<xsd:simpleContent>
+		<xsd:extension base="this:Length">
+		</xsd:extension>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+
+
+<xsd:attributeGroup name="AttrGroup">
+  <xsd:attribute name="attrgroup1" type="xsd:string"/>
+  <xsd:attribute name="attrgroup2" type="xsd:string"/>
+</xsd:attributeGroup>
+
+<!-- Not alias because extended with attributes -->
+<xsd:complexType name="ComplexSimpleNotAlias">
+	<xsd:simpleContent>
+		<xsd:extension base="this:Length">
+			<xsd:attributeGroup ref="this:AttrGroup"/>
+		</xsd:extension>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexSimpleAlias2">
+	<xsd:simpleContent>
+		<xsd:extension base="this:LengthAlias2">
+		</xsd:extension>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+<!-- Not alias because extended with attribute -->
+<xsd:complexType name="ComplexSimpleNotAlias2">
+	<xsd:simpleContent>
+		<xsd:extension base="this:LengthAlias2">
+			<xsd:attribute name="attr" type="xsd:string"/>
+		</xsd:extension>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexSimpleAlias3">
+	<xsd:simpleContent>
+		<xsd:extension base="this:ComplexSimpleNotAlias">
+		</xsd:extension>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+<!-- Not alias because extended with attribute -->
+<xsd:complexType name="ComplexSimpleNotAlias3">
+	<xsd:simpleContent>
+		<xsd:extension base="this:ComplexSimpleAlias3">
+			<xsd:attribute name="attr" type="xsd:string"/>
+		</xsd:extension>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexSimpleAlias4">
+	<xsd:simpleContent>
+		<xsd:extension base="this:ComplexSimpleNotAlias3">
+		</xsd:extension>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+<!-- Not alias because extended with attribute -->
+<xsd:complexType name="ComplexSimpleNotAlias4">
+	<xsd:simpleContent>
+		<xsd:extension base="this:ComplexSimpleNotAlias3">
+			<xsd:attribute name="attr2" type="xsd:string"/>
+		</xsd:extension>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+
+
+<xsd:complexType name="ComplexSimpleRestrictionAlias">
+	<xsd:simpleContent>
+		<xsd:restriction base="this:ComplexSimpleNotAlias4"/>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+<xsd:complexType name="ComplexSimpleRestrictionAlias2">
+	<xsd:simpleContent>
+		<xsd:restriction base="this:ComplexSimpleRestrictionAlias"/>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+<!-- Not alias because the minLength of the base is restricted to 5 -->
+<xsd:complexType name="ComplexSimpleRestrictionNotAlias">
+	<xsd:simpleContent>
+		<xsd:restriction base="this:ComplexSimpleNotAlias4">
+			<xsd:minLength value="5"/>
+		</xsd:restriction>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+<!-- Not alias because the attr attribute is required -->
+<xsd:complexType name="ComplexSimpleRestrictionNotAlias2">
+	<xsd:simpleContent>
+		<xsd:restriction base="this:ComplexSimpleRestrictionAlias2">
+			<xsd:attribute name="attr" type="xsd:string" use="required"/>
+		</xsd:restriction>
+	</xsd:simpleContent>
+</xsd:complexType>
+
+
+
+
+</xsd:schema>
diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc
index 221f65b90..6557a1e2c 100644
--- a/xsdconvert/ComplexType.cc
+++ b/xsdconvert/ComplexType.cc
@@ -306,6 +306,7 @@ void ComplexType::loadWithValues() {
         f->type.upload(atts.base);
         f->setReference(atts.base);
         f->addVariant(V_untagged);
+        f->mode = restrictionMode;
         complexfields.push_back(f);
         basefield = f;
         actfield = f;
@@ -329,6 +330,7 @@ void ComplexType::loadWithValues() {
         f->type.upload(atts.base);
         f->setReference(atts.base);
         f->addVariant(V_untagged);
+        f->mode = extensionMode;
         complexfields.push_back(f);
         basefield = f;
         actfield = f;
@@ -823,7 +825,7 @@ void ComplexType::applyReference(const SimpleType & other, const bool on_attribu
   }
 
   builtInBase = other.getBuiltInBase();
-
+  
   length.applyReference(other.getLength());
   pattern.applyReference(other.getPattern());
   enumeration.applyReference(other.getEnumeration());
@@ -1149,11 +1151,12 @@ void ComplexType::printToFile(FILE * file, const unsigned level, const bool is_u
     }else {
       fprintf(file, "%s %s", type.convertedValue.c_str(), name.convertedValue.c_str());
     }
-    fprintf(file, "\n{\n");
-
-    if (attribfields.empty() && complexfields.empty()) {
-      fprintf(file, "\n");
-    }
+    if(type.convertedValue == "record" || type.convertedValue == "union"){
+      fprintf(file, "\n{\n");
+      if (attribfields.empty() && complexfields.empty()) {
+        fprintf(file, "\n");
+      }
+    } 
 
     for (List<ComplexType*>::iterator c = complexfields.begin(), nextField; c; c = nextField) {
       nextField = c->Next;
@@ -1304,7 +1307,9 @@ void ComplexType::printToFile(FILE * file, const unsigned level, const bool is_u
   }
 
   if (top) {
-    fprintf(file, "}");
+    if(type.convertedValue == "record" || type.convertedValue == "union"){
+      fprintf(file, "}");
+    }
     if(mode == listMode){
       fprintf(file, " %s", name.convertedValue.c_str());
     }
@@ -1620,8 +1625,11 @@ void ComplexType::applyAttributeExtension(ComplexType * found_CT, AttributeType
 }
 
 //Attribute restriction logic when restricting complextypes
-void ComplexType::applyAttributeRestriction(ComplexType * found_CT) {
-  for (List<AttributeType*>::iterator attr = attribfields.begin(), nextAttr; attr; attr = nextAttr) {
+bool ComplexType::applyAttributeRestriction(ComplexType * found_CT) {
+  bool isModifiedAttr = false;
+  // when the element is nillable the attributes are in the parent
+  ComplexType * me = parent != NULL && nillable ? parent : this;
+  for (List<AttributeType*>::iterator attr = me->attribfields.begin(), nextAttr; attr; attr = nextAttr) {
     nextAttr = attr->Next;
     bool l = false;
     for (List<AttributeType*>::iterator attr2 = found_CT->attribfields.begin(); attr2; attr2 = attr2->Next) {
@@ -1634,31 +1642,35 @@ void ComplexType::applyAttributeRestriction(ComplexType * found_CT) {
     if (!l) {
       delete attr->Data;
       attr->Data = NULL;
-      attribfields.remove(attr);
+      me->attribfields.remove(attr);
     }
   }
   size_t size = found_CT->attribfields.size();
-  size_t size2 = attribfields.size();
+  size_t size2 = me->attribfields.size();
   size_t i = 0;
   List<AttributeType*>::iterator attr = found_CT->attribfields.begin();
   for (; i < size; attr = attr->Next, i = i + 1) {
     bool l = false;
     size_t j = 0;
-    List<AttributeType*>::iterator attr2 = attribfields.begin();
+    List<AttributeType*>::iterator attr2 = me->attribfields.begin();
     for (; j < size2; attr2 = attr2->Next, j = j + 1) {
       if (attr->Data->getName().convertedValue == attr2->Data->getName().convertedValue &&
         attr->Data->getType().convertedValue == attr2->Data->getType().convertedValue && !attr2->Data->getUsed()) {
         l = true;
+        if(attr->Data->getUseVal() != attr2->Data->getUseVal()){
+          isModifiedAttr = true;
+        }
         attr2->Data->setUsed(true);
         break;
       }
     }
     if (!l) {
       AttributeType * newAttrib = new AttributeType(*attr->Data);
-      attribfields.push_back(newAttrib);
-      setParent(this, newAttrib);
+      me->attribfields.push_back(newAttrib);
+      setParent(me, newAttrib);
     }
   }
+  return isModifiedAttr;
 }
 
 void ComplexType::addNameSpaceAsVariant(RootType * root, RootType * other) {
@@ -1837,28 +1849,73 @@ void ComplexType::resolveSimpleTypeExtension() {
         if (ct->resolved == No) {
           ct->referenceResolving();
         }
-        basefield->outside_reference.set_resolved(ct);
-        ct->basefield->addToNameDepList(basefield);
-        basefield->nameDep = ct->basefield;
-        basefield->mode = extensionMode;
-        basefield->applyReference(*ct->basefield, true);
-        addNameSpaceAsVariant(basefield, ct->basefield);
-        applyAttributeExtension(ct);
+        // If an alias
+        if (attribfields.empty()) {
+          for (List<ComplexType*>::iterator field = complexfields.begin(); field; field = field->Next) {
+            field->Data->setInvisible();
+          }
+
+          for (List<AttributeType*>::iterator field = attribfields.begin(); field; field = field->Next) {
+            field->Data->setInvisible();
+          }
+          
+          basefield->setInvisible();
+          type.upload(st->getName().originalValueWoPrefix);
+          ct->addToNameDepList(this);
+          nameDep = ct;
+          addNameSpaceAsVariant(this, st);
+          alias = ct;
+        } else {
+          
+          while (ct != NULL && ct->getAlias() != NULL) {
+            ct = (ComplexType*)ct->getAlias();
+          }
+          
+          basefield->outside_reference.set_resolved(ct);
+          ct->basefield->addToNameDepList(basefield);
+          basefield->nameDep = ct->basefield;
+          basefield->mode = extensionMode;
+          basefield->applyReference(*ct->basefield, true);
+          addNameSpaceAsVariant(basefield, ct->basefield);
+          applyAttributeExtension(ct);
+        }
       } else {
         if (!st->getReference().empty() && !st->getReference().is_resolved()) {
           st->referenceResolving();
         }
-        st->addToNameDepList(basefield);
-        basefield->nameDep = st;
-        addNameSpaceAsVariant(basefield, st);
-        const Mstring old_type = basefield->getType().originalValueWoPrefix;
-        basefield->applyReference(*st);
-        // If st has enumeration then the type is restored to the original value
-        // because enumerations cannot be extended here and this way we just
-        // create an alias.
-        if (st->getEnumeration().modified) {
-          basefield->setTypeValue(old_type);
-          basefield->getEnumeration().modified = false;
+        
+        bool hasRestrOrExt = basefield->hasRestrictionOrExtension();
+        // If an alias
+        if(!hasRestrOrExt && attribfields.empty()){
+          // Set the fields and attributes invisible
+          for (List<ComplexType*>::iterator field = complexfields.begin(); field; field = field->Next) {
+            field->Data->setInvisible();
+          }
+
+          for (List<AttributeType*>::iterator field = attribfields.begin(); field; field = field->Next) {
+            field->Data->setInvisible();
+          }
+          basefield->setInvisible();
+          type.upload(st->getName().originalValueWoPrefix);
+          st->addToNameDepList(this);
+          nameDep = st;
+          addNameSpaceAsVariant(this, st);
+          alias = st;
+        } else {
+          while(st != NULL && st->getAlias() != NULL) {
+            st = st->getAlias();
+          }
+          basefield->builtInBase = st->getBuiltInBase();
+          addNameSpaceAsVariant(basefield, st);
+          const Mstring old_type = basefield->getType().originalValueWoPrefix;
+          basefield->applyReference(*st);
+          // If st has enumeration then the type is restored to the original value
+          // because enumerations cannot be extended here and this way we just
+          // create an alias.
+          if (st->getEnumeration().modified) {
+            basefield->setTypeValue(old_type);
+            basefield->getEnumeration().modified = false;
+          }
         }
       }
     } else if(!isBuiltInType(basefield->getType().convertedValue)){
@@ -1880,6 +1937,28 @@ void ComplexType::resolveSimpleTypeRestriction() {
       TTCN3ModuleInventory::getInstance().incrNumErrors();
       return;
     }
+    bool hasRestrOrExt = basefield->hasRestrictionOrExtension();
+    // If an alias
+    if(!hasRestrOrExt && attribfields.empty()){
+      type.upload(st->getName().convertedValue);
+      st->addToNameDepList(this);
+      nameDep = st;
+      alias = st;
+      basefield->setInvisible();
+      for (List<ComplexType*>::iterator field = complexfields.begin(); field; field = field->Next) {
+        field->Data->setInvisible();
+      }
+
+      for (List<AttributeType*>::iterator field = attribfields.begin(); field; field = field->Next) {
+        field->Data->setInvisible();
+      }
+      addNameSpaceAsVariant(this, st);
+      return;
+    }
+    
+    while (st != NULL && st->getAlias() != NULL) {
+      st = st->getAlias();
+    }
     basefield->outside_reference.set_resolved(st);
     if (st->getXsdtype() != n_NOTSET) {
       ComplexType * ct = (ComplexType*) st;
@@ -1924,6 +2003,7 @@ void ComplexType::resolveSimpleTypeRestriction() {
       return;
     }
     
+    // Alias not possible here, because basefield->outside_reference is empty
     basefield->outside_reference.set_resolved(ct);
     if (ct != NULL) {
       if (ct->resolved == No) {
@@ -1963,6 +2043,25 @@ void ComplexType::resolveComplexTypeExtension() {
       if (ct->resolved == No) {
         ct->referenceResolving();
       }
+      // it is an alias
+      if (complexfields.empty() && attribfields.empty()) {
+        type.upload(ct->getName().convertedValue);
+        
+        for (List<ComplexType*>::iterator field = complexfields.begin(); field; field = field->Next) {
+          field->Data->setInvisible();
+        }
+        
+        for (List<AttributeType*>::iterator field = attribfields.begin(); field; field = field->Next) {
+          field->Data->setInvisible();
+        }
+        ct->addToNameDepList(this);
+        nameDep = ct;
+        alias = ct;
+        return;
+      }
+      while (ct != NULL && ct->getAlias() != NULL) {
+        ct = (ComplexType*)ct->getAlias();
+      }
       List<AttributeType*>::iterator anyAttr = attribfields.begin();
       for (; anyAttr; anyAttr = anyAttr->Next) {
         if (anyAttr->Data->isAnyAttribute()) {
@@ -2018,12 +2117,32 @@ void ComplexType::resolveComplexTypeRestriction() {
       TTCN3ModuleInventory::getInstance().incrNumErrors();
       return;
     }
-    if(ct->getXsdtype() != n_NOTSET){
+    if(ct->getXsdtype() != n_NOTSET) {
       if (ct->resolved == No) {
         ct->referenceResolving();
       }
+      ComplexType * maybeAlias = ct;
+      while (maybeAlias != NULL && maybeAlias->getAlias() != NULL) {
+        maybeAlias = (ComplexType*)maybeAlias->getAlias();
+      }
+      bool isModifiedAttr = applyAttributeRestriction(maybeAlias);
+      if(!isModifiedAttr && !hasComplexRestriction(maybeAlias)){
+        type.upload(ct->getName().convertedValue);
+        
+        for (List<ComplexType*>::iterator field = complexfields.begin(); field; field = field->Next) {
+          field->Data->setInvisible();
+        }
+        
+        for (List<AttributeType*>::iterator field = attribfields.begin(); field; field = field->Next) {
+          field->Data->setInvisible();
+        }
+        ct->addToNameDepList(this);
+        nameDep = ct;
+        alias = ct;
+        return;
+      }
+      
       outside_reference.set_resolved(ct);
-      applyAttributeRestriction(ct);
 
       size_t size = complexfields.size();
       size_t i = 0;
@@ -2067,6 +2186,28 @@ bool ComplexType::hasMatchingFields(const List<ComplexType*>& mainList, const Li
     return true;
 }
 
+bool ComplexType::hasComplexRestriction(ComplexType* ct) const {
+  if(complexfields.size() != ct->complexfields.size() || hasRestrictionOrExtension()) {
+    return true;
+  }
+  
+  for(List<ComplexType*>::iterator field = complexfields.begin(); field; field = field->Next) {
+    for(List<ComplexType*>::iterator field2 = ct->complexfields.begin(); field2; field2 = field2->Next) {
+      if(field->Data->getName().convertedValue.getValueWithoutPrefix(':') == field2->Data->getName().convertedValue.getValueWithoutPrefix(':') &&
+         field->Data->getType().convertedValue.getValueWithoutPrefix(':') == field2->Data->getType().convertedValue.getValueWithoutPrefix(':')) {
+        if(field->Data->getMinOccurs() == field2->Data->getMinOccurs() && field->Data->getMaxOccurs() == field2->Data->getMaxOccurs()){
+          if(field->Data->hasComplexRestriction(field2->Data)) {
+            return true;
+          }
+        } else {
+          return true;
+        }
+      }
+    }
+  }
+  return false;
+}
+
 void ComplexType::resolveUnion(SimpleType *st) {
   if (parent != NULL && parent->with_union && xsdtype == n_simpleType && !outside_reference.empty()) {
     if (st->getXsdtype() != n_NOTSET) {
diff --git a/xsdconvert/ComplexType.hh b/xsdconvert/ComplexType.hh
index dd40d9bef..83a639b86 100644
--- a/xsdconvert/ComplexType.hh
+++ b/xsdconvert/ComplexType.hh
@@ -87,7 +87,8 @@ private:
   ComplexType * parentTypeSubsGroup;
 
 
-  void applyAttributeRestriction(ComplexType * found_CT);
+  // Returns true if the attributes really restricted and not just aliased
+  bool applyAttributeRestriction(ComplexType * found_CT);
   void applyAttributeExtension(ComplexType * found_CT, AttributeType * anyAttr = NULL);
   void nameConversion_names(const List<NamespaceType> & ns);
   void nameConversion_types(const List<NamespaceType> & ns);
@@ -114,6 +115,8 @@ private:
   void resolveComplexTypeRestriction();
   void resolveUnion(SimpleType *st);
   bool hasMatchingFields(const List<ComplexType*>& a, const List<ComplexType*>& b) const;
+  // True if a restriction really restricts the type not just aliases
+  bool hasComplexRestriction(ComplexType* ct) const;
 
   void printVariant(FILE * file);
 
diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc
index 24fcbdf74..1aa78caaf 100644
--- a/xsdconvert/SimpleType.cc
+++ b/xsdconvert/SimpleType.cc
@@ -50,6 +50,7 @@ SimpleType::SimpleType(XMLParser * a_parser, TTCN3Module * a_module, ConstructTy
 , addedToTypeSubstitution(false)
 , block(not_set)
 , inList(false)
+, alias(NULL)
 , parent(NULL) {
 }
 
@@ -75,6 +76,7 @@ SimpleType::SimpleType(const SimpleType& other)
 , addedToTypeSubstitution(other.addedToTypeSubstitution)
 , block(other.block)
 , inList(other.inList)
+, alias(other.alias)
 , parent(NULL) {
   length.parent = this;
   pattern.parent = this;
@@ -598,6 +600,9 @@ void SimpleType::referenceResolving() {
 }
 
 void SimpleType::referenceForST(SimpleType * found_ST) {
+  while(found_ST != NULL && found_ST->alias != NULL){
+    found_ST = found_ST->alias;
+  }
   outside_reference.set_resolved(found_ST);
   if (in_name_only)
     return;
@@ -611,15 +616,27 @@ void SimpleType::referenceForST(SimpleType * found_ST) {
 
   if (mode == listMode || mode == restrictionAfterListMode)
     return;
-
+  
+  bool hasRestrOrExt = hasRestrictionOrExtension();
+  
   length.applyReference(found_ST->length);
   pattern.applyReference(found_ST->pattern);
   enumeration.applyReference(found_ST->enumeration);
   whitespace.applyReference(found_ST->whitespace);
   value.applyReference(found_ST->value);
+  
+  if(!hasRestrOrExt){
+    length.modified = false;
+    pattern.modified = false;
+    enumeration.modified = false;
+    whitespace.modified = false;
+    value.modified = false;
+    alias = found_ST;
+  }
 
   mode = found_ST->mode;
-  if (found_ST->mode != listMode && found_ST->mode != restrictionAfterListMode) {
+  if (found_ST->mode != listMode && found_ST->mode != restrictionAfterListMode
+      && hasRestrOrExt) {
     type.upload(found_ST->getType().convertedValue);
   }
 }
@@ -811,6 +828,15 @@ void SimpleType::applyRefAttribute(const Mstring& ref_value) {
   }
 }
 
+bool SimpleType::hasRestrictionOrExtension() const {
+  return
+    enumeration.modified ||
+    length.modified ||
+    value.modified ||
+    pattern.modified ||
+    whitespace.modified;
+}
+
 void SimpleType::printToFile(FILE * file) {
   if (!visible) {
     return;
diff --git a/xsdconvert/SimpleType.hh b/xsdconvert/SimpleType.hh
index 1babbe327..37de61867 100644
--- a/xsdconvert/SimpleType.hh
+++ b/xsdconvert/SimpleType.hh
@@ -34,7 +34,7 @@ public:
 
   LengthType(SimpleType * p_parent);
   // Default copy constructor and destructor are used
-
+  
   void applyReference(const LengthType & other);
   void applyFacets();
   void printToFile(FILE * file) const;
@@ -51,7 +51,7 @@ public:
 
   PatternType(SimpleType * p_parent);
   // Default copy constructor and destructor are used
-
+  
   void applyReference(const PatternType & other);
   void applyFacet();
   void printToFile(FILE * file) const;
@@ -73,7 +73,7 @@ public:
 
   EnumerationType(SimpleType * p_parent);
   // Default copy constructor and destructor are used
-
+  
   void applyReference(const EnumerationType & other);
   void applyFacets();
   void sortFacets();
@@ -243,6 +243,9 @@ protected:
   bool inList;
   // We are inside a list if inList is true and mode == listMode
   
+  // If this type is an alias then the alias field points to the original type
+  SimpleType * alias;
+  
   //Element substitution
   void addToSubstitutions();
 
@@ -398,6 +401,14 @@ public:
           nameDepList.push_back(t);
       }
   }
+  
+  SimpleType * getAlias() const {
+      return alias;
+  }
+  
+  // Returns true if the type really restricts or extends the type not
+  // just aliases it.
+  bool hasRestrictionOrExtension() const;
 
 };
 
-- 
GitLab