From 068b5270d4862bbbcbc23ccf81f7c4d04c431da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9F=D0=BE=D0=B3=D0=BE=D1=80=D0=B5=D0=BB=D0=BE=D0=B2?= Date: Sat, 9 Feb 2019 18:20:39 +0300 Subject: [PATCH] fix #1692 --- .../SugarVisitors/PropertyDesugarVisitor.cs | 14 +++++++++++++- TestSuite/autoproperty7.pas | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 TestSuite/autoproperty7.pas diff --git a/SyntaxVisitors/SugarVisitors/PropertyDesugarVisitor.cs b/SyntaxVisitors/SugarVisitors/PropertyDesugarVisitor.cs index d0de8b878..448778626 100644 --- a/SyntaxVisitors/SugarVisitors/PropertyDesugarVisitor.cs +++ b/SyntaxVisitors/SugarVisitors/PropertyDesugarVisitor.cs @@ -1,6 +1,7 @@ using PascalABCCompiler.SyntaxTree; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; @@ -13,7 +14,18 @@ namespace SyntaxVisitors.SugarVisitors get { return new PropertyDesugarVisitor(); } } - public override void visit(simple_property _simple_property) + public override void visit(class_members _class_members) + { + foreach (var member in _class_members.members) + { + if (member is simple_property) + { + Desugar(member as simple_property); + } + } + } + + private void Desugar(simple_property _simple_property) { var property_parent_node = _simple_property.Parent; while (property_parent_node != null && property_parent_node.GetType() != typeof(class_members)) diff --git a/TestSuite/autoproperty7.pas b/TestSuite/autoproperty7.pas new file mode 100644 index 000000000..985657ac8 --- /dev/null +++ b/TestSuite/autoproperty7.pas @@ -0,0 +1,12 @@ +type + TSome = auto class + public + auto property A: byte; + auto property B: object; + end; + +begin + var node := new TSome(1, nil); + assert(node.A = 1); + assert(node.B = nil); +end. \ No newline at end of file