Why doesn’t the following simple type definition compile?
type
SomeType = class(TObject)
ID: Cardinal;
end;
AnotherType = class(TObject)
Some: SomeType;
property ID: Cardinal read Some.ID; // E2467
end;
It gives E2467 Record or object type required, this occurs when trying to access a property from a variable that is not a record or object.
But Some is an object, right? Is this a compiler bug (I’m using the latest XE2)? If this is expected behavior, what’s the proper way to do what I’m trying to do?
The property accessors must be either direct data members or direct methods of the same class that the property belongs to.
Try:
The error message pretty much says it all. “Some.ID” is not a record or object. It is a data member of a data member – different thing.