@Override

Specifies that a method or property overrides the same method or property inherited from a parent class.

Instructions

Declaration contexts
You can use @Override only with Method and Property. These procedures must be open in the parent class or trait. Open procedures have one of the modifiers @Open or @Abstract.
Mixd modifiers
You cannot put @Override together with @Abstract and @Shared in the same declaration.
Equivalent signatures
A method or property with @Override must have a signature that is almost the same as the procedure it overrides:
  • The names must be the same.
  • The return types must be the same.
  • If the procedure is generic, the number of generic parameters must be the same. And if the procedure has constraints (Where), these must also be the same.
  • For Method, the parameters must be the same number, in the same sequence, with the same data types and modifiers, for example, ByRef.

Applies to

Examples

Basic example

@Open Class BaseClass
    @Open Method MyMethod()
    End Method
End Class

Class DerivedClass Is BaseClass
    @Override Method MyMethod()
    End Method
End Class

Override an abstract class

Require ViviFire.Math

@Abstract Class Shape
    Method Area() As Real64
End Class

Class Circle Is Shape
    Constructor Var
        radius As Real64
    End Constructor
    @Override Method Area() As Real64
        Return Pi * radius ^ 2
    End Method
End Class