TCustomAttribute and class internal types
TCustomAttribute and class internal types
Consider
Default = class(TCustomAttribute)
DefaultVal: Integer;
constructor Create(const aVal:Integer);
end;
TMyBaseClass = class(TObject)
public
constructor Create; virtual; // handles attributes
end;
// 1
TMyClass = class(TMyBaseClass)
public
[Default(5)]
Value: Integer;
end;
which is ok, versus
TMyBaseClass = class(TObject)
public
type
Default = class(TCustomAttribute)
DefaultVal: Integer;
constructor Create(const aVal:Integer);
end;
constructor Create; virtual; // handles attributes
end;
// 2
TMyClass = class(TMyBaseClass)
public
[Default(5)]
W1025 Unsupported language feature: 'custom attribute'
Value: Integer;
end;
as well as
// 3
TMyClass = class(TMyBaseClass)
public
[TMyBaseClass.Default(5)]
E2010 Incompatible types: 'TQuerySet' and 'TCustomAttribute'
Value: Integer;
end;
Question
I can understand why //2 is a fail, since internal types have to be qualified, but why is //3 not a compatible type?
Update: Feature Request added to QP
https://quality.embarcadero.com/browse/RSP-13512
Consider
Default = class(TCustomAttribute)
DefaultVal: Integer;
constructor Create(const aVal:Integer);
end;
TMyBaseClass = class(TObject)
public
constructor Create; virtual; // handles attributes
end;
// 1
TMyClass = class(TMyBaseClass)
public
[Default(5)]
Value: Integer;
end;
which is ok, versus
TMyBaseClass = class(TObject)
public
type
Default = class(TCustomAttribute)
DefaultVal: Integer;
constructor Create(const aVal:Integer);
end;
constructor Create; virtual; // handles attributes
end;
// 2
TMyClass = class(TMyBaseClass)
public
[Default(5)]
W1025 Unsupported language feature: 'custom attribute'
Value: Integer;
end;
as well as
// 3
TMyClass = class(TMyBaseClass)
public
[TMyBaseClass.Default(5)]
E2010 Incompatible types: 'TQuerySet' and 'TCustomAttribute'
Value: Integer;
end;
Question
I can understand why //2 is a fail, since internal types have to be qualified, but why is //3 not a compatible type?
Update: Feature Request added to QP
https://quality.embarcadero.com/browse/RSP-13512
Comments
Post a Comment