123456789_123456789_123456789_123456789_123456789_

Class: TypeProf::Type::Class

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: TypeProf::Type
Defined in: lib/typeprof/type.rb

Overview

or Module

Constant Summary

::TypeProf::Type - Inherited

Builtin, DummySubstitution

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(kind, idx, type_params, superclass, name) ⇒ Class

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 486

def initialize(kind, idx, type_params, superclass, name)
  @kind = kind # :class | :module
  @idx = idx
  @type_params = type_params
  @superclass = superclass
  raise if @kind == :class && !@superclass
  @_name = name
end

Instance Attribute Details

#idx (readonly)

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 495

attr_reader :kind, :idx, :type_params, :superclass

#kind (readonly)

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 495

attr_reader :kind, :idx, :type_params, :superclass

#superclass (readonly)

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 495

attr_reader :kind, :idx, :type_params, :superclass

#superclass_type_args (rw)

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 496

attr_accessor :superclass_type_args

#type_params (readonly)

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 495

attr_reader :kind, :idx, :type_params, :superclass

Instance Method Details

#consistent?(other) ⇒ Boolean

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 514

def consistent?(other)
  case other
  when Type::Class
    ty = self
    loop do
      # ad-hoc
      return false if !ty || !other # module

      return true if ty.idx == other.idx
      return false if ty.idx == 0 # Object
      ty = ty.superclass
    end
  when Type::Instance
    return true if other.klass == Type::Builtin[:obj] || other.klass == Type::Builtin[:class] || other.klass == Type::Builtin[:module]
    return false
  else
    false
  end
end

#inspect

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 498

def inspect
  if @_name
    "#{ @_name }@#{ @idx }"
  else
    "Class[#{ @idx }]"
  end
end

#method_dispatch_info

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 510

def method_dispatch_info
  [self, true, false]
end

#screen_name(scratch)

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 506

def screen_name(scratch)
  "singleton(#{ scratch.get_class_name(self) })"
end

#substitute(_subst, _depth)

[ GitHub ]

  
# File 'lib/typeprof/type.rb', line 534

def substitute(_subst, _depth)
  self
end