class Steep::Interface::Builder::Config
def self.empty
def self.empty new(self_type: nil, variable_bounds: {}) end
def initialize(self_type:, class_type: nil, instance_type: nil, variable_bounds:)
def initialize(self_type:, class_type: nil, instance_type: nil, variable_bounds:) @self_type = self_type @class_type = class_type @instance_type = instance_type @variable_bounds = variable_bounds end
def subst
def subst if self_type || class_type || instance_type Substitution.build([], [], self_type: self_type, module_type: class_type, instance_type: instance_type) end end
def upper_bound(a)
def upper_bound(a) variable_bounds.fetch(a, nil) end
def validate_class_type
def validate_class_type validate_fvs(:class_type, class_type) end
def validate_fvs(name, type)
def validate_fvs(name, type) if type fvs = type.free_variables if fvs.include?(AST::Types::Self.instance) raise "#{name} cannot include 'self' type: #{type}" end if fvs.include?(AST::Types::Instance.instance) Steep.logger.fatal { "#{name} cannot include 'instance' type: #{type}" } raise "#{name} cannot include 'instance' type: #{type}" end if fvs.include?(AST::Types::Class.instance) raise "#{name} cannot include 'class' type: #{type}" end end end
def validate_instance_type
def validate_instance_type validate_fvs(:instance_type, instance_type) end
def validate_self_type
def validate_self_type validate_fvs(:self_type, self_type) end