Sha256: fc1d2e3a660407e03535aa50ac15d44523dc3d38e6d50f03002d4cc9f32adae8
Contents?: true
Size: 1.78 KB
Versions: 4
Compression:
Stored size: 1.78 KB
Contents
require 'forwardable' require 'yoda/typing/types/rbs_type_wrapper_interface' module Yoda module Typing module Types class InstanceType extend Forwardable include RbsTypeWrapperInterface # @return [Model::Environment] delegate environment: :singleton_type # @return [RbsTypeWrapperInterface] attr_reader :singleton_type # @param singleton_type [Type, SingletonType] def initialize(singleton_type) @singleton_type = singleton_type end # @return [RBS::Types::t] def rbs_type @rbs_type ||= make_instance(singleton_type.rbs_type) end # @return [Model::Values::Base] def value @value ||= singleton_type.value.instance_value end # @return [InstanceType] def instance_type InstanceType.new(self) end # @deprecated Use {#value} to access referred objects. # @return [Store::Objects::Base] def klass value.referred_objects.first end # @return [String] def to_s rbs_type.to_s end # @param pp [PP] def pretty_print(pp) pp.object_group(self) do pp.breakable pp.text "@rbs_type=" pp.pp rbs_type.to_s end end private # @param rbs_type [RBS::Types::t] # @return [RBS::Types::t] def make_instance(rbs_type) if rbs_type.is_a?(RBS::Types::ClassSingleton) RBS::Types::ClassInstance.new(name: rbs_type.name, args: [], location: nil) elsif rbs_type.respond_to?(:type_map) rbs_type.type_map(&method(:make_instance)) else rbs_type end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems