pyscripter 752 Posted May 18 (edited) I would like to share the following in case you encounter the same issue. Class and Record Helpers (Delphi) - RAD Studio states that: Quote You can define and associate multiple helpers with a single type. However, only zero or one helper applies in any specific location in source code. The helper defined in the nearest scope will apply. Class or record helper scope is determined in the normal Delphi fashion (for example, right to left in the unit's uses clause). Actually, this is not entirely correct. Consider the following: Unit HelperUnit1.pas: TObjectHelper1 = class helper for TObject procedure Test; end; Unit2 HelperUnit2.pas: TObjectHelper2 = class helper for TObject procedure Test; end; Unit SupportClasses,pas: uses HelperUnit1; type TMyClass: class end; Unit MainUnit.pas interface implementation uses SupportClasses, HelperUnit2; begin var MyClass:= TMyClass.Create; MyClass.Test; end; MyClass.Test will use the HelperUnit1.TObjectHelper1.Test implementation even if HelperUnit1 is not even in scope, let alone being "in nearest scope". So it appears that if a class helper is in scope where a class is defined, it is used unconditionally in all units of a project. If not, then what it is stated in the documentation applies. Edited May 18 by pyscripter 2 Share this post Link to post
Remy Lebeau 1597 Posted May 18 (edited) 8 hours ago, pyscripter said: I would like to share the following in case you encounter the same issue. ... Actually, this is not entirely correct. ... So it appears that if a class helper is in scope where a class is defined, it is used unconditionally in all units of a project. If not, then what it is stated in the documentation applies. Did you report the problem to Embarcadero? It is either an error in the documentation, or a bug in the compiler. Edited May 18 by Remy Lebeau Share this post Link to post
pyscripter 752 Posted May 19 1 hour ago, Remy Lebeau said: Did you report the problem to Embarcadero? It is either an error in the documentation, or a bug in the compiler. Class helpers compiler or documentation error - RAD Studio Service - Jira Service Management Share this post Link to post
FredS 140 Posted May 19 On 5/18/2025 at 7:20 AM, pyscripter said: So it appears that if a class helper is in scope where a class is defined, it is used unconditionally in all units of a project. May explain an old bug report I file where adding a second record helper (access to private as a bug fix) lower down in a unit would be ignored. There may be a workaround for class helpers, in this case you can inherit from the original class helper. THelper2 = class helper(THelper1) for TMyClass 2 Share this post Link to post