The point is that somewhere in the code, there is a function like this:
useint(foo::AbstractFoo{Integer}) = factorial(foo.field1)
or any other function, which necessarily needs an Integer as field1. As I have a lot of Foos, I would like to make sure that I do not make some sort of ‘typo’ and create
struct OneMoreFoo <: AbstractFoo{Integer}
field1::Float64
end
by mistake. Therefore I am looking for a coding pattern, which disallows this.
While your solution does solve the issue, SomeFoo is actually a parametric type, while I would like to have it parameter-less.
Maybe the cleanest solution is to create a macro, which does this for me.