diff --git a/lib/parlour/rbi_generator/constant.rb b/lib/parlour/rbi_generator/constant.rb index 9bab631ec..f3ecc784f 100644 --- a/lib/parlour/rbi_generator/constant.rb +++ b/lib/parlour/rbi_generator/constant.rb @@ -102,9 +102,11 @@ def describe_attrs sig { override.void } def generalize_from_rbi! - # There's a good change this is an untyped constant, so rescue - # ParseError and use untyped - @value = (TypeParser.parse_single_type(@value) if String === @value) rescue Types::Untyped.new + if @value.is_a?(String) + # There's a good chance this is an untyped constant, so rescue + # ParseError and use untyped + @value = TypeParser.parse_single_type(@value) rescue Types::Untyped.new + end end end end