In a similar line, it would be nice if there were a way to predeclare instance variables so that there was a canonical place to put type annotations for instance variables. Ruby type checkers right now all invent their own ways of declaring the types of instance variables.
If Ruby supported something like
class A
def @instance_variable
def self.@singleton_class_instance_variable
def @@class_variable
end
as a way to pre-declare the object shape at class load time, it would be an obvious place to also let type checkers declare the types of these instance variables.
(Not saying that this specific syntax is ideal, but rather just that having some syntax for declaring instance variables at load time, not method run time, would solve both the "predetermined object shape" and "predetermined ivar types" problems.)