E2094
Delphi Programming Language
Severity: ModerateWhat Does This Error Mean?
E2094 means you declared a method with 'override' in a subclass, but the same-named method in the parent class is static (not virtual). Only virtual or abstract methods can be overridden — static methods are resolved at compile time and cannot participate in polymorphism. Fix it by either removing 'override' (to hide the parent method) or changing the parent method to 'virtual'.
Affected Models
- Delphi 10.4 Sydney
- Delphi 11 Alexandria
- Delphi 12 Athens
- Embarcadero RAD Studio
- Free Pascal / Lazarus
Common Causes
- Adding 'override' to a method in a subclass when the parent class method is not marked virtual or abstract
- Attempting to override a class method or static method that is resolved at compile time
- Misremembering which methods in a library class are virtual versus static
- Copy-pasting override from another method and applying it to a non-virtual one
- Incorrectly assuming all methods in Delphi classes are virtual by default
How to Fix It
-
Go to the parent class declaration and find the method named in the error. Check whether it is declared as 'virtual' or 'abstract'.
If the parent method has no 'virtual' keyword, it is a static method and cannot be overridden.
-
If you want polymorphism (different behavior per subclass), change the parent method to 'virtual' and keep 'override' in the subclass.
Adding 'virtual' to the parent method changes how the method is dispatched — calls through base class variables will now call the subclass version.
-
If you only want to provide a different version in the subclass without polymorphism, remove 'override' from the subclass method.
Without 'override', the subclass method hides (not overrides) the parent method. Calls through a base class variable will still call the parent version.
-
If the parent class is from a library you cannot modify and the method is not virtual, you cannot use polymorphism for this method — use the hiding approach instead.
Some developers add the 'reintroduce' directive to suppress the warning about hiding a parent method: procedure DoWork; reintroduce;
-
Verify you are looking at the correct level of inheritance — if there are multiple ancestors, the method must be virtual at the level where it is first declared.
Virtual dispatch flows down from the first virtual declaration. Introducing 'virtual' in a middle class for a method that was static higher up also causes issues.
When to Call a Professional
This is a compiler error — no professional repair needed. Fix it by reading the error message and correcting the code. The Delphi IDE highlights the exact line causing the problem.
Frequently Asked Questions
Are Delphi methods virtual by default like in Java or C#?
No — in Delphi, methods are static by default. You must explicitly mark them as 'virtual' to enable polymorphic dispatch. Java and C# make all methods virtual by default (Java) or require 'virtual' and 'override' (C#). Delphi's approach gives better performance for the common case where polymorphism is not needed.
What is the difference between hiding and overriding a method in Delphi?
Overriding replaces the parent's method in the virtual dispatch table — calls through a base class variable use the subclass version. Hiding creates a new method with the same name in the subclass — calls through a base class variable still use the parent version. Overriding is what you usually want for polymorphism. Hiding is rarely the right choice and often a sign of a design issue.
What does 'reintroduce' do in Delphi?
Reintroduce suppresses the compiler warning that appears when you declare a method in a subclass with the same name as a non-virtual parent method. It tells the compiler 'I know I am hiding the parent method, and this is intentional'. It does not enable polymorphism — it only silences the warning about hiding.