Переглянути джерело

compiler: don't allow to publish class properties + test

git-svn-id: trunk@14640 -
paul 15 роки тому
батько
коміт
9513b50d26
3 змінених файлів з 21 додано та 1 видалено
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/pdecvar.pas
  3. 19 0
      tests/test/tclass14b.pp

+ 1 - 0
.gitattributes

@@ -8900,6 +8900,7 @@ tests/test/tclass12b.pp svneol=native#text/pascal
 tests/test/tclass12c.pp svneol=native#text/pascal
 tests/test/tclass13.pp svneol=native#text/pascal
 tests/test/tclass14a.pp svneol=native#text/pascal
+tests/test/tclass14b.pp svneol=native#text/pascal
 tests/test/tclass2.pp svneol=native#text/plain
 tests/test/tclass3.pp svneol=native#text/plain
 tests/test/tclass4.pp svneol=native#text/plain

+ 1 - 1
compiler/pdecvar.pas

@@ -423,7 +423,7 @@ implementation
                 end;
            end;
          if ((p.visibility=vis_published) or is_dispinterface(aclass)) and
-            not(p.propdef.is_publishable) then
+            (not(p.propdef.is_publishable) or (sp_static in p.symoptions)) then
            begin
              Message(parser_e_cant_publish_that_property);
              p.visibility:=vis_public;

+ 19 - 0
tests/test/tclass14b.pp

@@ -0,0 +1,19 @@
+{ %FAIL}
+program tclass14b;
+
+{$ifdef fpc}
+  {$mode delphi}{$H+}
+{$endif}
+
+type
+  TSomeClass = class
+  public
+    class var
+      FSomeField: Integer;
+  published
+    // class properties are not for sreaming therefore publishing them is not supported
+    class property SomeField: Integer read FSomeField write FSomeField;
+  end;
+
+begin
+end.