From 85f95b0d05905b31a49ed5793e720ae24e0d1a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Fri, 4 Oct 2019 19:28:13 +0200 Subject: [PATCH] fix #2066 --- TestSuite/namespaces/nspartial1.pas | 11 +++++++++++ TestSuite/namespaces/nspartial2.pas | 12 ++++++++++++ TestSuite/use_ns_partial.pas | 11 +++++++++++ TreeConverter/TreeConversion/syntax_tree_visitor.cs | 4 ++-- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 TestSuite/namespaces/nspartial1.pas create mode 100644 TestSuite/namespaces/nspartial2.pas create mode 100644 TestSuite/use_ns_partial.pas diff --git a/TestSuite/namespaces/nspartial1.pas b/TestSuite/namespaces/nspartial1.pas new file mode 100644 index 000000000..5d6581956 --- /dev/null +++ b/TestSuite/namespaces/nspartial1.pas @@ -0,0 +1,11 @@ +namespace nspartial; + +type + T = partial class + public procedure Test1; + begin + Inc(i); + end; + end; + +end. \ No newline at end of file diff --git a/TestSuite/namespaces/nspartial2.pas b/TestSuite/namespaces/nspartial2.pas new file mode 100644 index 000000000..06e9aff43 --- /dev/null +++ b/TestSuite/namespaces/nspartial2.pas @@ -0,0 +1,12 @@ +namespace nspartial; + +type + T = partial class + public i: integer; + public procedure Test2; + begin + Inc(i); + end; + end; + +end. \ No newline at end of file diff --git a/TestSuite/use_ns_partial.pas b/TestSuite/use_ns_partial.pas new file mode 100644 index 000000000..38279560a --- /dev/null +++ b/TestSuite/use_ns_partial.pas @@ -0,0 +1,11 @@ +//nopabcrtl +{$includenamespace 'namespaces/nspartial1.pas'} +{$includenamespace 'namespaces/nspartial2.pas'} + +uses nspartial; +begin + var o := new T; + o.Test1; + o.Test2; + assert(o.i = 2); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index f5d5d8533..27dadf562 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -10968,9 +10968,9 @@ namespace PascalABCCompiler.TreeConverter AddError(get_location(cl_def), "TYPE_PREDEFINITION_NOT_ALLOWED"); common_type_node ctn = null; if (td.type_name is template_type_name) - ctn = context.advanced_create_type(td.type_name.name + "`" + (td.type_name as template_type_name).template_args.Count, get_location(td.type_name), (td.type_def as class_definition).keyword == class_keyword.Interface, false); + ctn = context.advanced_create_type(td.type_name.name + "`" + (td.type_name as template_type_name).template_args.Count, get_location(td.type_name), (td.type_def as class_definition).keyword == class_keyword.Interface, (cl_def.attribute & SyntaxTree.class_attribute.Partial) == SyntaxTree.class_attribute.Partial); else - ctn = context.advanced_create_type(td.type_name.name, get_location(td.type_name), (td.type_def as class_definition).keyword == class_keyword.Interface, false); + ctn = context.advanced_create_type(td.type_name.name, get_location(td.type_name), (td.type_def as class_definition).keyword == class_keyword.Interface, (cl_def.attribute & SyntaxTree.class_attribute.Partial) == SyntaxTree.class_attribute.Partial); ctn.ForwardDeclarationOnly = true; if ((td.type_def as class_definition).keyword == class_keyword.Interface) ctn.IsInterface = true;