Browse Source

Mantis #22790 was fixed by partial specializations addition in revision 27861

+ added test

git-svn-id: trunk@27894 -
svenbarth 11 years ago
parent
commit
69a8445472
4 changed files with 123 additions and 0 deletions
  1. 3 0
      .gitattributes
  2. 46 0
      tests/webtbs/tw22790a.pp
  3. 36 0
      tests/webtbs/tw22790b.pp
  4. 38 0
      tests/webtbs/tw22790c.pp

+ 3 - 0
.gitattributes

@@ -13791,6 +13791,9 @@ tests/webtbs/tw2274.pp svneol=native#text/plain
 tests/webtbs/tw22741.pp svneol=native#text/plain
 tests/webtbs/tw22744.pp svneol=native#text/pascal
 tests/webtbs/tw2277.pp svneol=native#text/plain
+tests/webtbs/tw22790a.pp svneol=native#text/pascal
+tests/webtbs/tw22790b.pp svneol=native#text/pascal
+tests/webtbs/tw22790c.pp svneol=native#text/pascal
 tests/webtbs/tw22796.pp svneol=native#text/plain
 tests/webtbs/tw2280.pp svneol=native#text/plain
 tests/webtbs/tw22860.pp svneol=native#text/plain

+ 46 - 0
tests/webtbs/tw22790a.pp

@@ -0,0 +1,46 @@
+{ %NORUN }
+
+program tw22790a;
+
+{$MODE DELPHI}
+
+type
+  TBinaryRelationMethod<TOperand> =
+    function (const a, b: TOperand): Boolean of object;
+
+  TWrapper1<TOperand> = record
+    class procedure Sort(lessThan: TBinaryRelationMethod<TOperand>); static;
+  end;
+
+  TWrapper2<TOperand> = class
+  strict private
+    type
+      POperand = ^TOperand;
+
+      TDereferencingAdapter = class
+        function LessThan(const a, b: POperand): Boolean;
+      end;
+  public
+    procedure Sort;
+  end;
+
+class procedure TWrapper1<TOperand>.Sort(
+  lessThan: TBinaryRelationMethod<TOperand>);
+begin
+end;
+
+function TWrapper2<TOperand>.TDereferencingAdapter.LessThan(
+  const a, b: POperand): Boolean;
+begin
+end;
+
+procedure TWrapper2<TOperand>.Sort;
+begin
+  with TDereferencingAdapter.Create do begin
+    TWrapper1<POperand>.Sort(LessThan);  { Error: Incompatible types ... }
+    Free;
+  end;
+end;
+
+begin
+end.

+ 36 - 0
tests/webtbs/tw22790b.pp

@@ -0,0 +1,36 @@
+{ %NORUN }
+
+program tw22790b;
+
+{$MODE DELPHI}
+
+type
+  TPredicateMethod<TOperand> = function (const x: TOperand): Boolean of object;
+
+  TWrapper<TOperand> = class
+  strict private
+    type
+      POperand = ^TOperand;
+      TDereferencingAdapter = class
+        function F(const x: POperand): Boolean;
+      end;
+  public
+    procedure Z;
+  end;
+
+function TWrapper<TOperand>.TDereferencingAdapter.F(const x: POperand): Boolean;
+begin
+end;
+
+procedure TWrapper<TOperand>.Z;
+var
+  pred: TPredicateMethod<POperand>;
+begin
+  with TDereferencingAdapter.Create do begin
+    pred := F;  { Error: Incompatible types ... }
+    Free;
+  end;
+end;
+
+begin
+end.

+ 38 - 0
tests/webtbs/tw22790c.pp

@@ -0,0 +1,38 @@
+{ %NORUN }
+
+program tw22790c;
+
+{$MODE DELPHI}
+
+type
+  TPredicateMethod<TOperand> = function (const x: TOperand): Boolean of object;
+
+  TWrapper<TOperand> = class
+  strict private
+    type
+      POperand = ^TOperand;
+      TPredicateMethodForPOperand = TPredicateMethod<POperand>;
+      TDereferencingAdapter = class
+        function F(const x: POperand): Boolean;
+      end;
+  public
+    procedure Z;
+  end;
+
+function TWrapper<TOperand>.TDereferencingAdapter.F(const x: POperand): Boolean;
+begin
+end;
+
+procedure TWrapper<TOperand>.Z;
+var
+  pred: TPredicateMethodForPOperand;
+    { Error: Generics without specialization cannot be used as ... }
+begin
+  with TDereferencingAdapter.Create do begin
+    pred := F;
+    Free;
+  end;
+end;
+
+begin
+end.