The Delphi Bug List

Entry No.
504
コンパイラ - コンパイル中のエラー
Internal error SY1703 (Delphi 3)、SY2149 (Delphi 4)、SY2192 (Delphi 5)、SY2358 (Kylix)、SY2394 (Delphi 6)
1.02 2.01 3.0 3.01 3.02 4.0 4.01 4.02 4.03 5.0 5.01 6.0 6.01 6.02 Kylix 1.0
Absent Absent Exists Exists Exists Exists Exists Exists Exists Exists Exists Exists Exists Exists Exists
解説
Reported by Vladimir Merzliakov; checked by Reinier Sterkenburg
再現方法:
任意のプロジェクトに以下のユニットを追加してコンパイルしてください。
unit uTest504;

interface

type
  TClass1 = object
  protected
    function Func1: integer;
    property Prop1: integer read Func1;
  end;

  TClass2 = object(TClass1)
  public
    property Prop1;
  end;

  TClass3 = object(TClass1)
  public
    property Prop1: integer read Func1;
  end;

function Main: integer;

implementation

function TClass1.Func1;
begin
  Result := 1;
end;

function Main: integer;
var
  C2: TClass2;
  C3: TClass3;
begin
  Result := C3.Prop1; // 問題なし
  Result := C2.Prop1; // Internal error SY2149 によりコンパイル停止
end;

end.
特徴:
  1. 古いタイプのオブジェクト(TClass1)が protected のプロパティ(Prop1)を持ち
  2. Prop1 が read メソッドを持ち
  3. Tlass1 のサブクラス(TClass2)が Prop1 の可視性を public に変更し
  4. 変数(C2)の型が TClass2 の場合
式 C2.Prop1 のところで、コンパイラはエラーメッセージ "Internal error SY2149" を発生させます。
解決策 / 回避方法
古いタイプのオブジェクトでは可視性を変更せず、代わりにサブクラスでそのプロパティを再定義してください。
Latest update of this entry: 2002-04-03
本家 The Delphi Bug List のエントリーはこちら
The Delphi Bug List 日本語訳 へ