Yes, the only option is to split up your attribute declarations, just like how you would have done if you were defining separate getter/setter methods for them, unless all your attributes are of the same type.
The reason for this is that Sorbet, in the DSL phase of its operation, actually uses the sig
on an attr_reader
/attr_writer
/attr_accessor
declaration to define the sig
on the synthetic methods that are produced by those declarations. Thus, a single getter for attr_reader
, a single setter for attr_writer
and a getter/setter pair for attr_accessor
are generated synthetically and the sig
s are applied to them.
As a result of this, this would be valid:
sig { returns(String) }
attr_reader :some_string_attr, :other_string_attr
but this would not be:
sig { returns(String, User) }
attr_reader :some_string_attr, :some_user_attr