Browse Source

* Determine publishable property type only when specializing a generic

Michaël Van Canneyt 4 months ago
parent
commit
dc0e6f4aa8
3 changed files with 34 additions and 1 deletions
  1. 2 1
      compiler/pdecvar.pas
  2. 16 0
      tests/test/tgeneric122.pp
  3. 16 0
      tests/test/tgeneric123.pp

+ 2 - 1
compiler/pdecvar.pas

@@ -515,7 +515,8 @@ implementation
                   message(parser_e_no_property_found_to_override);
                 end;
            end;
-         if ((p.visibility=vis_published) or is_dispinterface(astruct)) then
+         if ((p.visibility=vis_published) or is_dispinterface(astruct))
+             and not (astruct.is_generic and (p.propdef.typ=undefineddef)) then
            begin
              { ignore is_publishable for interfaces (related to $M+ directive).
                $M has effect on visibility of default section for classes.

+ 16 - 0
tests/test/tgeneric122.pp

@@ -0,0 +1,16 @@
+{$mode objfpc}
+
+type
+  {$M+}
+  generic myclass<T> = class
+  Private
+    FData : T;
+  published
+    property Data : T read FData;
+  end;
+  
+  TA = specialize myclass<integer>;
+//  TB = specialize myclass<text>;
+      
+begin
+end.  

+ 16 - 0
tests/test/tgeneric123.pp

@@ -0,0 +1,16 @@
+{%FAIL}
+{$mode objfpc}
+
+type
+  {$M+}
+  generic myclass<T> = class
+  Private
+    FData : T;
+  published
+    property Data : T read FData;
+  end;
+  
+  TB = specialize myclass<text>;
+      
+begin
+end.