ソースを参照

compiler: allow use of default properties for records (issue #0019098)

git-svn-id: trunk@17334 -
paul 14 年 前
コミット
56cd7b3450
3 ファイル変更25 行追加1 行削除
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/pexpr.pas
  3. 23 0
      tests/test/terecs10.pp

+ 1 - 0
.gitattributes

@@ -9694,6 +9694,7 @@ tests/test/tenum5.pp svneol=native#text/plain
 tests/test/tenum6.pp svneol=native#text/pascal
 tests/test/tenumerators1.pp svneol=native#text/pascal
 tests/test/terecs1.pp svneol=native#text/pascal
+tests/test/terecs10.pp svneol=native#text/pascal
 tests/test/terecs2.pp svneol=native#text/pascal
 tests/test/terecs3.pp svneol=native#text/pascal
 tests/test/terecs4.pp svneol=native#text/pascal

+ 1 - 1
compiler/pexpr.pas

@@ -1927,7 +1927,7 @@ implementation
                _LECKKLAMMER:
                   begin
                     if is_class_or_interface_or_object(p1.resultdef) or
-                      is_dispinterface(p1.resultdef) then
+                      is_dispinterface(p1.resultdef) or is_record(p1.resultdef) then
                       begin
                         { default property }
                         protsym:=search_default_property(tobjectdef(p1.resultdef));

+ 23 - 0
tests/test/terecs10.pp

@@ -0,0 +1,23 @@
+program terecs10;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest = record
+    function GetTest(Index: Integer): Integer;
+    property Test[Index: Integer]: Integer read GetTest; default;
+  end;
+
+function TTest.GetTest(Index: Integer): Integer;
+begin
+  Result := Index;
+end;
+
+var
+  t: TTest;
+begin
+  if t[42] <> 42 then
+    halt(1);
+end.