lib/steep/interface/builder.rb in steep-1.9.0 vs lib/steep/interface/builder.rb in steep-1.9.1

- old
+ new

@@ -52,17 +52,18 @@ def upper_bound(a) variable_bounds.fetch(a, nil) end end - attr_reader :factory, :object_shape_cache, :union_shape_cache, :singleton_shape_cache + attr_reader :factory, :object_shape_cache, :union_shape_cache, :singleton_shape_cache, :implicitly_returns_nil - def initialize(factory) + def initialize(factory, implicitly_returns_nil:) @factory = factory @object_shape_cache = {} @union_shape_cache = {} @singleton_shape_cache = {} + @implicitly_returns_nil = implicitly_returns_nil end def shape(type, config) Steep.logger.tagged "shape(#{type})" do if shape = raw_shape(type, config) @@ -824,9 +825,11 @@ method_type end def add_implicitly_returns_nil(annotations, method_type) + return method_type unless implicitly_returns_nil + if annotations.find { _1.string == "implicitly-returns-nil" } return_type = method_type.type.return_type method_type = method_type.with( type: method_type.type.with(return_type: AST::Types::Union.build(types: [return_type, AST::Builtin.nil_type])) )