Browse Source

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

+ added test

git-svn-id: trunk@27896 -
svenbarth 11 years ago
parent
commit
47407d2d7a
2 changed files with 71 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 70 0
      tests/webtbs/tw23279.pp

+ 1 - 0
.gitattributes

@@ -13824,6 +13824,7 @@ tests/webtbs/tw23204.pp svneol=native#text/plain
 tests/webtbs/tw23212.pp svneol=native#text/plain
 tests/webtbs/tw23212.pp svneol=native#text/plain
 tests/webtbs/tw2323.pp svneol=native#text/plain
 tests/webtbs/tw2323.pp svneol=native#text/plain
 tests/webtbs/tw23270.pp svneol=native#text/pascal
 tests/webtbs/tw23270.pp svneol=native#text/pascal
+tests/webtbs/tw23279.pp svneol=native#text/pascal
 tests/webtbs/tw2328.pp svneol=native#text/plain
 tests/webtbs/tw2328.pp svneol=native#text/plain
 tests/webtbs/tw23299.pp svneol=native#text/pascal
 tests/webtbs/tw23299.pp svneol=native#text/pascal
 tests/webtbs/tw2332.pp svneol=native#text/plain
 tests/webtbs/tw2332.pp svneol=native#text/plain

+ 70 - 0
tests/webtbs/tw23279.pp

@@ -0,0 +1,70 @@
+{ %NORUN }
+
+program tw23279;
+
+{$MODE DELPHI}
+
+type
+  TPolicy<T> = class abstract
+    procedure Z(const a: T); virtual; abstract;
+  end;
+
+  TWrapper<T, S> = class
+  private
+    FPolicy: TPolicy<T>;
+  public
+    constructor Create(policy: TPolicy<T>);
+    procedure W(const a: T);
+  end;
+
+  TSpecialWrapper<S> = class(TWrapper<Integer, S>)
+  strict private
+    type
+      TSpecialPolicy = class(TPolicy<Integer>)
+        procedure Z(const a: Integer); override;
+      end;
+  public
+    constructor Create;
+    destructor Destroy; override;
+  end;
+
+{ TWrapper<T, S> }
+
+constructor TWrapper<T, S>.Create;
+begin
+end;
+
+procedure TWrapper<T, S>.W(const a: T);
+begin
+  FPolicy.Z(a);
+end;
+
+{ TSpecialWrapper<S>.TSpecialPolicy }
+
+procedure TSpecialWrapper<S>.TSpecialPolicy.Z(const a: Integer);
+begin
+  Writeln(a);
+end;
+
+{ TSpecialWrapper<S> }
+
+constructor TSpecialWrapper<S>.Create;
+begin
+  inherited Create(TSpecialPolicy.Create);
+    { Warning: Constructing a class "TSpecialPolicy" with abstract method "Z";
+      if Z() is CLASS or CLASS STATIC the warning is suppressed but the code
+      is still faulty }
+end;
+
+destructor TSpecialWrapper<S>.Destroy;
+begin
+  FPolicy.Free;
+end;
+
+begin
+  with TSpecialWrapper<Byte>.Create do begin
+    W(0);
+    Free;
+  end;
+end.
+