ThisType is also referred to as SelfType>, in Eiffel it is called like this.
The purpose of ThisType is to allow co-variant argument type changes for opereations such as numeric.infix +(a numeric) in heir features such as i32, where this should be i32.infix +(a i32).
Workaround using parametric types
As a first solution, Fuzion uses constrained type parameters to mimic ThisType: As an example. feature numeric is declared generically as numeric(T numeric.type), and the type argument T is carried through heirs such as integer, which is declared as integer(T integer.type) : numeric T, wrappingInteger declared as wrappingInteger(T wrappingInteger.type) : integer T, and i32 declared as i32(val i32) : wrappingInteger i32. This works, but it is cumbersome, in particular when the inheritance graph becomes more complex (e.g. i32 also inherits from hasInterval, which uses the same mechanism to mimic ThisType).
- Sukyoung Ryo: ThisType for Object-Oriented Languages: From Theory to Practice.
- Saito andd Igarashi presented a paper Matching ThisType to Subtyping.
ThisType in Fuzion
Since features in Fuzion can be nested arbitrarily, in general there could be an aribrary number of ThisTypes visible at the same time. So, the language should provide a syntax similar to the syntax to access an outer instance,
to access an outer type. One solution would be to replace the keyword this by type to refer to the corresponding ThisType of an outer feature, i.e.,
could be used in a feature abc.def.ghi.jkl to refer to the actual type of feature at two levels outside the current feature.