class TypeProf::Type::Class

Attributes

idx[R]
kind[R]
superclass[R]
superclass_type_args[RW]
type_params[R]

Public Class Methods

new(kind, idx, type_params, superclass, name) click to toggle source
# File typeprof-0.21.9/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

Public Instance Methods

consistent?(other) click to toggle source
# File typeprof-0.21.9/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() click to toggle source
# File typeprof-0.21.9/lib/typeprof/type.rb, line 498
def inspect
  if @_name
    "#{ @_name }@#{ @idx }"
  else
    "Class[#{ @idx }]"
  end
end
method_dispatch_info() click to toggle source
# File typeprof-0.21.9/lib/typeprof/type.rb, line 510
def method_dispatch_info
  [self, true, false]
end
screen_name(scratch) click to toggle source
# File typeprof-0.21.9/lib/typeprof/type.rb, line 506
def screen_name(scratch)
  "singleton(#{ scratch.get_class_name(self) })"
end
substitute(_subst, _depth) click to toggle source
# File typeprof-0.21.9/lib/typeprof/type.rb, line 534
def substitute(_subst, _depth)
  self
end