Delphi XE2 - Nested class functions do not compile

I am updating some outdated third-party components from a Delphi 6 source to XE2.

A third-party source has a nested class function in a class procedure. The layout of the exact working copy that will not be executed:

type TMyClass1 = class public class procedure DoSomething; end; { TMyClass1 } class procedure TMyClass1.DoSomething; class function DoSomethingelse: boolean; begin result := false; end; begin end; 

trying to compile this gives an error saying that doSomethingelse is an undeclared identifier. Now I can (presumably) resolve this by pulling the nested function one level, but is there a compiler option that I can set to prevent this? Is this something that has recently changed? Anyone else run into this issue?

thanks

+4
source share
1 answer

To compile your code in XE2, simply delete the class keyword of the DoSomethingelse definition, even if this code compiles in older versions of delphi (I tested your code in Delphi 5, 7, and 2007). Do not see the point (or difference) of the declaration of the built-in (internal) procedure or function with the class keyword.

+6
source

Source: https://habr.com/ru/post/1381832/


All Articles