Overriding rules for mix and extend


I would like to know the exact rules related to overriding fields and methods for types that extend / mix or remix other types.


  • can you change the type of the field?
  • what happens to annotations


  • can you change the signature of a function?
  • can you change the implementation of a function?
1 Like


The answer to your questions on methods are in:

Override and Overload Rules

To avoid mistakes, the type system does not allow accidental overriding. If a type mixes in a type that declares a function, it may not re-declare that function with the same parameters. Instead, it must use override syntax to indicate that it is overriding the function in a mixin type.

If the method is declared with with different parameters, that constitutes an overload.

Method signature matching is done only by the parameter types; the return value is not significant.

A type that mixes in an abstract type is assumed to implement all abstract functions, so it only needs to re-declare them abstract if they will not be implemented.

A function cannot be made private in a type that mixes in a type in which it was public since the function forms part of the contract of the mixin type.

An override cannot change a function from static to member or vice versa. It is not possible to have a method with the same name as both a static and a member method (including overloads).

Yes, you can change the implementation of a function.

I don’t know the answer to your questions on data fields, or annotations.



Becareful when overriding fields and changing types, you may endup with problems especially on columns that’s been indexed like in this thread Value too long for type character varying(5).



In regard to fields, I believe the rule with extending/mixing types is that you can change the type of a field only if that type is more specific, i.e.

extendable entity type MyBaseType {
     cat: Cat
type Tiger mixes Cat 

* This works
type MyMixedType mixes MyBaseType {
     cat: Tiger
entity type Dog {

* Field conflict: 'cat' is defined both in type MyMixedType and its mixin MyBaseType
type MyMixedType mixes MyBaseType {
     cat: Dog