pyscripter 751 Posted 10 hours ago (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 10 hours ago by pyscripter 1 Share this post Link to post
Remy Lebeau 1593 Posted 2 hours ago (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 2 hours ago by Remy Lebeau Share this post Link to post
pyscripter 751 Posted 58 minutes ago 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