0
votes

I can't invoke class completion (via Ctrl + Shift + C) using Embarcadero RAD Studio XE6, if I have following class structure. Program works fine, but the IDE causes the following error. If I want to use it, I must comment DescriptionArray, which is somewhat annoying.

Therefore I would like to know, if anyone knows, where is the problem, or what I'm doing wrong.

GT_Class = class
type
  TCustomEnum = (ceValue1, ceValue2, ceValue3, ceValue4);
  TCustomSet = set of TCustomEnum;

const
  DescriptionArray : array[TCustomEnum] of string = ('Description1', 'Description2', 'Description3', 'Description4');
end;

Error Message

Error message

1
I think it is because there is nothing to complete in your class in the first place.R. Beiboer
I can reproduce the error in XE6 but not in Berlin. Putting a visibility infront of the const though removed the error when invoking class completion.Stefan Glienke
What do you expect to happen when you invoke class completion for this class?R. Beiboer
This code snippet works just fine for me in Seattle. Looks like a bug in the IDE that has since been resolved.Johan
@StefanGlienke: Found it: "If a member's declaration appears without its own visibility specifier, the member has the same visibility as the one that precedes it. Members at the beginning of a class declaration that do not have a specified visibility are by default published, provided the class is compiled in the {$M+} state or is derived from a class compiled in the {$M+} state; otherwise, such members are public". So indeed, if inherited from TObject, it is public. If inherited from TPersistent (which is compiled with $M+), it is published.Rudy Velthuis

1 Answers

0
votes

Solved by Stefan Glienke in comment. Actually it's a bug in Delphi XE6 and in other versions it has been resolved. You need to define visibility, public in this case, even if it shouldn't be needed.

GT_Class = class
public
  type
    TCustomEnum = (ceValue1, ceValue2, ceValue3, ceValue4);
    TCustomSet = set of TCustomEnum;

  const
    DescriptionArray : array[TCustomEnum] of string = ('Description1', 'Description2', 'Description3', 'Description4');
end;