浏览代码

compiler: change check for current in try_consume_unitsym - don't use current_unit in check because specialize code does not replace this variable (fixes bug #0015591)

git-svn-id: trunk@16489 -
paul 14 年之前
父节点
当前提交
668cd1f3c0
共有 4 个文件被更改,包括 42 次插入2 次删除
  1. 2 0
      .gitattributes
  2. 9 2
      compiler/pbase.pas
  3. 9 0
      tests/webtbs/tw15591.pp
  4. 22 0
      tests/webtbs/uw15591.pp

+ 2 - 0
.gitattributes

@@ -10629,6 +10629,7 @@ tests/webtbs/tw15467.pp svneol=native#text/pascal
 tests/webtbs/tw15500.pp svneol=native#text/plain
 tests/webtbs/tw15500.pp svneol=native#text/plain
 tests/webtbs/tw15504.pp svneol=native#text/plain
 tests/webtbs/tw15504.pp svneol=native#text/plain
 tests/webtbs/tw15530.pp svneol=native#text/pascal
 tests/webtbs/tw15530.pp svneol=native#text/pascal
+tests/webtbs/tw15591.pp svneol=native#text/pascal
 tests/webtbs/tw15592.pp svneol=native#text/plain
 tests/webtbs/tw15592.pp svneol=native#text/plain
 tests/webtbs/tw15599.pp svneol=native#text/plain
 tests/webtbs/tw15599.pp svneol=native#text/plain
 tests/webtbs/tw15607.pp svneol=native#text/plain
 tests/webtbs/tw15607.pp svneol=native#text/plain
@@ -11619,6 +11620,7 @@ tests/webtbs/uw13345y.pp svneol=native#text/plain
 tests/webtbs/uw13583.pp svneol=native#text/plain
 tests/webtbs/uw13583.pp svneol=native#text/plain
 tests/webtbs/uw14124.pp svneol=native#text/plain
 tests/webtbs/uw14124.pp svneol=native#text/plain
 tests/webtbs/uw14958.pp svneol=native#text/plain
 tests/webtbs/uw14958.pp svneol=native#text/plain
+tests/webtbs/uw15591.pp svneol=native#text/pascal
 tests/webtbs/uw15909.pp svneol=native#text/plain
 tests/webtbs/uw15909.pp svneol=native#text/plain
 tests/webtbs/uw17220.pp svneol=native#text/plain
 tests/webtbs/uw17220.pp svneol=native#text/plain
 tests/webtbs/uw17220a.pp svneol=native#text/plain
 tests/webtbs/uw17220a.pp svneol=native#text/plain

+ 9 - 2
compiler/pbase.pas

@@ -241,6 +241,8 @@ implementation
 
 
 
 
     function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume : ttoken):boolean;
     function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume : ttoken):boolean;
+      var
+        hmodule: tmodule;
       begin
       begin
         result:=false;
         result:=false;
         tokentoconsume:=_ID;
         tokentoconsume:=_ID;
@@ -250,8 +252,13 @@ implementation
             if not(srsym.owner.symtabletype in [staticsymtable,globalsymtable]) then
             if not(srsym.owner.symtabletype in [staticsymtable,globalsymtable]) then
               internalerror(200501154);
               internalerror(200501154);
             { only allow unit.symbol access if the name was
             { only allow unit.symbol access if the name was
-              found in the current module }
-            if srsym.owner.iscurrentunit then
+              found in the current module
+              we can use iscurrentunit because generic specializations does not
+              change current_unit variable }
+            hmodule:=find_module_from_symtable(srsym.Owner);
+            if not Assigned(hmodule) then
+              internalerror(201001120);
+            if hmodule.unit_index=current_filepos.moduleindex then
               begin
               begin
                 consume(_ID);
                 consume(_ID);
                 consume(_POINT);
                 consume(_POINT);

+ 9 - 0
tests/webtbs/tw15591.pp

@@ -0,0 +1,9 @@
+{ %norun% }
+program tw15591;
+{$mode objfpc}
+uses uw15591;
+type
+  TIntegerSmartArray = specialize GSmartArray<Integer>;
+begin
+end.
+

+ 22 - 0
tests/webtbs/uw15591.pp

@@ -0,0 +1,22 @@
+unit uw15591;
+{$mode objfpc}
+interface
+
+type
+  generic GSmartArray<TSomeType> = class
+  private
+    fItems :array of TSomeType;
+  public
+    function Length() :Integer;
+  end;
+
+  TBooleanSmartArray = specialize GSmartArray<Boolean>;
+
+implementation
+
+function GSmartArray.Length() :Integer;
+begin
+  Result := System.Length(fItems);
+end;
+
+end.