moduleSteepmoduleInterfaceclassInstantiatedattr_reader:typeattr_reader:methodsattr_reader:ivar_chainsdefinitialize(type:,methods:,ivar_chains:)@type=type@methods=methods@ivar_chains=ivar_chainsenddefivars@ivars||=ivar_chains.transform_values(&:type)enddef==(other)other.is_a?(self.class)&&other.type==type&&other.params==params&&other.methods==methods&&other.ivars==ivarsenddefsubst(s)self.class.new(type: type,methods: methods.transform_values{|type|type.subst(s)},ivar_chains: ivar_chains.transform_values{|chain|chain.subst(s)})endclassInvalidMethodOverrideError<StandardErrorattr_reader:typeattr_reader:current_methodattr_reader:super_methodattr_reader:resultdefinitialize(type:,current_method:,super_method:,result:)@type=type@current_method=current_method@super_method=super_method@result=resultsuper"Invalid override of `#{current_method.name}` in #{type}: definition in #{current_method.type_name} is not compatible with its super (#{super_method.type_name})"endendclassInvalidIvarOverrideError<StandardErrorattr_reader:typeattr_reader:ivar_nameattr_reader:current_ivar_typeattr_reader:super_ivar_typedefinitialize(type:,ivar_name:,current_ivar_type:,super_ivar_type:)@type=type@ivar_name=ivar_name@current_ivar_type=current_ivar_type@super_ivar_type=super_ivar_typesuper"Invalid override of `#{ivar_name}` in #{type}: #{current_ivar_type} is not compatible with #{super_ivar_type}"endenddefvalidate(check)methods.eachdo|_,method|validate_method(check,method)endivar_chains.eachdo|name,chain|validate_chain(check,name,chain)endenddefvalidate_chain(check,name,chain)returnunlesschain.parentthis_type=chain.typesuper_type=chain.parent.typecasewhenthis_type.is_a?(AST::Types::Any)&&super_type.is_a?(AST::Types::Any)# okelserelation=Subtyping::Relation.new(sub_type: this_type,super_type: super_type)result1=check.check(relation,constraints: Subtyping::Constraints.empty)result2=check.check(relation.flip,constraints: Subtyping::Constraints.empty)ifresult1.failure?||result2.failure?||this_type.is_a?(AST::Types::Any)||super_type.is_a?(AST::Types::Any)raiseInvalidIvarOverrideError.new(type: self.type,ivar_name: name,current_ivar_type: this_type,super_ivar_type: super_type)endendvalidate_chain(check,name,chain.parent)enddefvalidate_method(check,method)ifmethod.super_method&&!method.incompatible?result=check.check_method(method.name,method,method.super_method,assumption: Set.new,trace: Subtyping::Trace.new,constraints: Subtyping::Constraints.empty)ifresult.success?validate_method(check,method.super_method)elseraiseInvalidMethodOverrideError.new(type: type,current_method: method,super_method: method.super_method,result: result)endendenddefselect_method_type(&block)self.class.new(type: type,methods: methods.each.with_object({})do|(name,method),methods|methods[name]=Method.new(type_name: method.type_name,name: method.name,types: method.types.select(&block),super_method: method.super_method,attributes: method.attributes,)end.rejectdo|_,method|method.types.empty?end,ivar_chains: ivar_chains)endendendend