瀏覽代碼

Fix for Mantis #23776.

ninl.pas, tinlinenode.pass_typecheck:
  * don't generate a type error if Length() is used inside generics with a generic argument

+ added test

git-svn-id: trunk@27533 -
svenbarth 11 年之前
父節點
當前提交
256c852631
共有 3 個文件被更改,包括 23 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 7 1
      compiler/ninl.pas
  3. 15 0
      tests/webtbs/tw23776.pp

+ 1 - 0
.gitattributes

@@ -13819,6 +13819,7 @@ tests/webtbs/tw23667.pp svneol=native#text/plain
 tests/webtbs/tw23725.pp svneol=native#text/pascal
 tests/webtbs/tw23725.pp svneol=native#text/pascal
 tests/webtbs/tw23744.pp svneol=native#text/plain
 tests/webtbs/tw23744.pp svneol=native#text/plain
 tests/webtbs/tw2377.pp svneol=native#text/plain
 tests/webtbs/tw2377.pp svneol=native#text/plain
+tests/webtbs/tw23776.pp svneol=native#text/pascal
 tests/webtbs/tw2378.pp svneol=native#text/plain
 tests/webtbs/tw2378.pp svneol=native#text/plain
 tests/webtbs/tw23819.pp svneol=native#text/plain
 tests/webtbs/tw23819.pp svneol=native#text/plain
 tests/webtbs/tw2382.pp svneol=native#text/plain
 tests/webtbs/tw2382.pp svneol=native#text/plain

+ 7 - 1
compiler/ninl.pas

@@ -2772,7 +2772,13 @@ implementation
                           begin
                           begin
                             { will be handled in simplify }
                             { will be handled in simplify }
                           end;
                           end;
-                      end
+                      end;
+                    undefineddef :
+                      begin
+                        if not (df_generic in current_procinfo.procdef.defoptions) then
+                          CGMessage(type_e_mismatch);
+                        { otherwise nothing }
+                      end;
                     else
                     else
                       CGMessage(type_e_mismatch);
                       CGMessage(type_e_mismatch);
                   end;
                   end;

+ 15 - 0
tests/webtbs/tw23776.pp

@@ -0,0 +1,15 @@
+{ %NORUN }
+
+program tw23776;
+{$mode objfpc}
+type
+generic tg<T>= class
+    public
+        class function len(a: T): integer;
+end;
+    class function tg.len(a: T): integer;
+    begin
+        result:= length(a);
+    end;
+begin
+end.