Browse Source

* fix for issue introduced in r28862: the compiler considered also
dynamic arrays and fixed-length static arrays when looking for
overloads of array constructors, while these are not valid in
such cases (and it also gave an error afterwards when trying to
actually use them). This caused a lot of spurious "can't select
which overloaded routine to call" errors when using many JVM
routines

git-svn-id: trunk@29393 -

Jonas Maebe 10 năm trước cách đây
mục cha
commit
bad1b2a1c1
3 tập tin đã thay đổi với 26 bổ sung1 xóa
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/htypechk.pas
  3. 24 0
      tests/webtbs/tw19452a.pp

+ 1 - 0
.gitattributes

@@ -13752,6 +13752,7 @@ tests/webtbs/tw1938.pp svneol=native#text/plain
 tests/webtbs/tw19434a.pp svneol=native#text/plain
 tests/webtbs/tw19434b.pp svneol=native#text/plain
 tests/webtbs/tw19452.pp svneol=native#text/plain
+tests/webtbs/tw19452a.pp svneol=native#text/plain
 tests/webtbs/tw1948.pp svneol=native#text/plain
 tests/webtbs/tw19498.pp svneol=native#text/pascal
 tests/webtbs/tw19499.pp svneol=native#text/pascal

+ 1 - 1
compiler/htypechk.pas

@@ -2780,7 +2780,7 @@ implementation
                    eq:=compare_defs_ext(n.resultdef,def_to,n.nodetype,convtype,pdoper,cdoptions);
                    n.free;
                  end
-              else if (def_to.typ=arraydef) and
+              else if is_open_array(def_to) and
                       is_class_or_interface_or_dispinterface_or_objc_or_java(tarraydef(def_to).elementdef) and
                       is_array_constructor(currpt.left.resultdef) and
                       assigned(tarrayconstructornode(currpt.left).left) then

+ 24 - 0
tests/webtbs/tw19452a.pp

@@ -0,0 +1,24 @@
+{ %norun }
+
+{$mode objfpc}
+type
+  TMyObject = class;
+  TArr = array of TMyObject;
+  TMyObject = class
+  public
+    constructor Create(ar: array of TMyObject); overload;
+    constructor Create(ar: TArr); overload;
+  end;
+
+constructor TMyObject.Create(ar: array of TMyObject);
+begin
+end;
+
+constructor TMyObject.Create(ar: Tarr);
+begin
+end;
+
+begin
+  TMyObject.Create([nil]);
+end.
+