From 4165e1860fa9224417083e210f97598bbce99787 Mon Sep 17 00:00:00 2001 From: Ivan Bondarev Date: Sun, 2 Jul 2023 20:48:21 +0200 Subject: [PATCH] #2885 --- TestSuite/property11.pas | 20 ++++++++++++++++++++ TreeConverter/TreeRealization/generics.cs | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 TestSuite/property11.pas diff --git a/TestSuite/property11.pas b/TestSuite/property11.pas new file mode 100644 index 000000000..1fd6e2608 --- /dev/null +++ b/TestSuite/property11.pas @@ -0,0 +1,20 @@ +type + t1 = class(System.IEquatable>) + + public property Item[ind: integer]: integer read 1; default; + + public static procedure p1; + begin + var a := new t1; + //Ошибка: Нет индексного свойства по умолчанию для типа t1 + var x := a[0]; + assert(x = 1); + end; + + public function Equals(other: t1) := true; + + end; + +begin + t1&.p1; +end. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/generics.cs b/TreeConverter/TreeRealization/generics.cs index 62d3caf20..3289f7b3c 100644 --- a/TreeConverter/TreeRealization/generics.cs +++ b/TreeConverter/TreeRealization/generics.cs @@ -1626,6 +1626,18 @@ namespace PascalABCCompiler.TreeRealization } } + public override property_node default_property_node + { + get + { + if (default_property != null) + return default_property; + if (original_generic.default_property_node != null) + default_property = ConvertMember(original_generic.default_property_node) as common_property_node; + return default_property; + } + } + private List temp_names = new List(3); public override void add_name(string name, SymbolInfo si)