diff --git a/TestSuite/errors/err0391.pas b/TestSuite/errors/err0391.pas new file mode 100644 index 000000000..87a590cc8 --- /dev/null +++ b/TestSuite/errors/err0391.pas @@ -0,0 +1,13 @@ +type + + c1 = class where T: c1; + + end; + + c2 = class(c1>) + + end; + +begin + new c2; +end. \ No newline at end of file diff --git a/TestSuite/where13.pas b/TestSuite/where13.pas new file mode 100644 index 000000000..54c0e69db --- /dev/null +++ b/TestSuite/where13.pas @@ -0,0 +1,13 @@ +type + + c1 = class where T: c1; + + end; + + c2 = class(c1) + + end; + +begin + new c2; +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 836bd3323..d97b80bc0 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -3705,7 +3705,9 @@ namespace PascalABCCompiler.TreeConverter { if (context.converted_type.IsStatic) AddError(get_location(_class_definition), "STATIC_CLASS_CANNOT_HAVE_PARENT"); + context.skip_check_where_sections = true; type_node tn = ret.visit(_class_definition.class_parents.types[0]); + context.skip_check_where_sections = false; //if (tn == context.converted_type) if (type_table.original_types_equals(tn, context.converted_type)) AddError(new UndefinedNameReference(tn.name, get_location(_class_definition.class_parents.types[0]))); @@ -3737,6 +3739,8 @@ namespace PascalABCCompiler.TreeConverter //Добавляем интерфейс used_interfs.Add(tn, tn); type_table.AddInterface(context.converted_type, tn, get_location(_class_definition.class_parents.types[0])); + if (tn.is_generic_type_instance) + ret.visit(_class_definition.class_parents.types[0]); } else { @@ -3749,6 +3753,8 @@ namespace PascalABCCompiler.TreeConverter AddError(get_location(_class_definition.class_parents.types[0]), "CAN_NOT_INHERIT_FROM_GENERIC_PARAMETER"); } context.converted_type.SetBaseType(tn); + if (tn.is_generic_type_instance) + ret.visit(_class_definition.class_parents.types[0]); var type_instances = generic_convertions.get_type_instances(context.converted_type); if (type_instances != null) foreach (generic_type_instance_info gti in type_instances)