2
0
Эх сурвалжийг харах

# revisions: 42328,42329

git-svn-id: branches/fixes_3_2@43401 -
marco 5 жил өмнө
parent
commit
c4b9529d6b

+ 1 - 0
.gitattributes

@@ -16443,6 +16443,7 @@ tests/webtbs/tw3564.pp svneol=native#text/plain
 tests/webtbs/tw3567.pp svneol=native#text/plain
 tests/webtbs/tw3567.pp svneol=native#text/plain
 tests/webtbs/tw3572.pp svneol=native#text/plain
 tests/webtbs/tw3572.pp svneol=native#text/plain
 tests/webtbs/tw3573.pp svneol=native#text/plain
 tests/webtbs/tw3573.pp svneol=native#text/plain
+tests/webtbs/tw35735.pp svneol=native#text/pascal
 tests/webtbs/tw3576.pp svneol=native#text/plain
 tests/webtbs/tw3576.pp svneol=native#text/plain
 tests/webtbs/tw3577.pp svneol=native#text/plain
 tests/webtbs/tw3577.pp svneol=native#text/plain
 tests/webtbs/tw3578.pp svneol=native#text/plain
 tests/webtbs/tw3578.pp svneol=native#text/plain

+ 4 - 1
compiler/pdecobj.pas

@@ -1259,7 +1259,10 @@ implementation
                           begin
                           begin
                             if (idtoken=_GENERIC) and
                             if (idtoken=_GENERIC) and
                                 not (m_delphi in current_settings.modeswitches) and
                                 not (m_delphi in current_settings.modeswitches) and
-                                not fields_allowed then
+                                (
+                                  not fields_allowed or
+                                  is_objectpascal_helper(current_structdef)
+                                ) then
                               begin
                               begin
                                 if hadgeneric then
                                 if hadgeneric then
                                   Message(parser_e_procedure_or_function_expected);
                                   Message(parser_e_procedure_or_function_expected);

+ 10 - 0
compiler/pdecsub.pas

@@ -1050,6 +1050,16 @@ implementation
                              HideSym(srsym);
                              HideSym(srsym);
                              searchagain:=true;
                              searchagain:=true;
                            end
                            end
+                         else if (srsym.typ=typesym) and
+                             (sp_generic_dummy in srsym.symoptions) and
+                             (ttypesym(srsym).typedef.typ=undefineddef) then
+                           begin
+                             { this is a generic dummy symbol that has not yet
+                               been used; so we rename the dummy symbol and continue
+                               as if nothing happened }
+                             hidesym(srsym);
+                             searchagain:=true;
+                           end
                          else
                          else
                           begin
                           begin
                             {  we use a different error message for tp7 so it looks more compatible }
                             {  we use a different error message for tp7 so it looks more compatible }

+ 33 - 0
tests/webtbs/tw35735.pp

@@ -0,0 +1,33 @@
+{ %NORUN }
+
+program tw35735;
+
+{$Mode objfpc}
+
+uses
+  Classes, SysUtils;
+
+type
+
+  { TObjectHelper }
+
+  TObjectHelper = class helper for TObject
+  public
+    generic function Test<T>(): String;
+  end;
+
+{ TComponentHelper }
+
+generic function TObjectHelper.Test<T>: String;
+begin
+  Result := T.ClassName
+end;
+
+var
+  O: TObject;
+begin
+  O := TObject.Create;
+  WriteLn(O.specialize Test<TPersistent>);
+  O.Free;
+end.
+