diff --git a/lib/solargraph/complex_type/unique_type.rb b/lib/solargraph/complex_type/unique_type.rb index 4bbdda5b2..d5f67ae9f 100644 --- a/lib/solargraph/complex_type/unique_type.rb +++ b/lib/solargraph/complex_type/unique_type.rb @@ -302,7 +302,6 @@ def desc rooted_tags end - # @sg-ignore Need better if/elseanalysis # @return [String] def to_rbs if duck_type? @@ -311,8 +310,9 @@ def to_rbs 'bool' elsif name.downcase == 'nil' 'nil' - elsif name == GENERIC_TAG_NAME - all_params.first&.name + elsif name == GENERIC_TAG_NAME && !all_params.empty? + # @sg-ignore flow sensitive typing should be able to handle !empty? narrowing first to non-nil + all_params.first.name elsif %w[Class Module].include?(name) rbs_name elsif %w[Tuple Array].include?(name) && fixed_parameters?