123456789_123456789_123456789_123456789_123456789_

Class: RBS::Types::UntypedFunction

Relationships & Source Files
Inherits: Object
Defined in: lib/rbs/types.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(return_type:) ⇒ UntypedFunction

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1208

def initialize(return_type:)
  @return_type = return_type
end

Instance Attribute Details

#empty?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1258

def empty?
  true
end

#has_classish_type?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1266

def has_classish_type?
  return_type.has_classish_type?
end

#has_self_type?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1262

def has_self_type?
  return_type.has_self_type?
end

#return_type (readonly)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1206

attr_reader :return_type

#with_nonreturn_void?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1270

def with_nonreturn_void?
  false
end

Instance Method Details

#==(other) Also known as: #eql?

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1282

def ==(other)
  other.is_a?(UntypedFunction) && other.return_type == return_type
end

#each_param(&block)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1232

def each_param(&block)
  if block
    # noop
  else
    enum_for :each_param
  end
end

#each_type(&block)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1224

def each_type(&block)
  if block
    yield return_type
  else
    enum_for :each_type
  end
end

#eql?(other)

Alias for #==.

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1286

alias eql? ==

#free_variables(acc = Set.new)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1212

def free_variables(acc = Set.new)
  return_type.free_variables(acc)
end

#hash

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1288

def hash
  self.class.hash ^ return_type.hash
end

#map_type(&block)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1216

def map_type(&block)
  if block
    update(return_type: yield(return_type))
  else
    enum_for :map_type
  end
end

#param_to_s

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1274

def param_to_s
  "?"
end

#return_to_s

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1278

def return_to_s
  return_type.to_s(1)
end

#sub(subst)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1246

def sub(subst)
  map_type { _1.sub(subst) }
end

#to_json(state = _ = nil)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1240

def to_json(state = _ = nil)
  {
    return_type: return_type
  }.to_json(state)
end

#update(return_type: self.return_type)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1254

def update(return_type: self.return_type)
  UntypedFunction.new(return_type: return_type)
end

#with_return_type(ty)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 1250

def with_return_type(ty)
  update(return_type: ty)
end