lib/steep/drivers/utils/validator.rb in steep-0.5.1 vs lib/steep/drivers/utils/validator.rb in steep-0.6.0

- old
+ new

@@ -19,34 +19,31 @@ yield sig if block_given? case sig when AST::Signature::Interface yield_self do - instance_name = TypeName::Interface.new(name: sig.name) - instance_interface = builder.build(instance_name) + instance_interface = builder.build_interface(sig.name) args = instance_interface.params.map {|var| AST::Types::Var.fresh(var) } - instance_type = AST::Types::Name.new_interface(name: sig.name, args: args) + instance_type = AST::Types::Name::Interface.new(name: sig.name, args: args) instance_interface.instantiate(type: instance_type, args: args, instance_type: instance_type, module_type: nil).validate(check) end when AST::Signature::Module yield_self do - instance_name = TypeName::Instance.new(name: sig.name) - instance_interface = builder.build(instance_name) + instance_interface = builder.build_instance(sig.name, with_initialize: true) instance_args = instance_interface.params.map {|var| AST::Types::Var.fresh(var) } - module_name = TypeName::Module.new(name: sig.name) - module_interface = builder.build(module_name) + module_interface = builder.build_module(sig.name) module_args = module_interface.params.map {|var| AST::Types::Var.fresh(var) } - instance_type = AST::Types::Name.new_instance(name: sig.name, args: instance_args) - module_type = AST::Types::Name.new_module(name: sig.name, args: module_args) + instance_type = AST::Types::Name::Instance.new(name: sig.name, args: instance_args) + module_type = AST::Types::Name::Module.new(name: sig.name) stdout.puts "👀 Validating instance methods..." if verbose instance_interface.instantiate(type: instance_type, args: instance_args, instance_type: instance_type, @@ -59,20 +56,18 @@ module_type: module_type).validate(check) end when AST::Signature::Class yield_self do - instance_name = TypeName::Instance.new(name: sig.name) - instance_interface = builder.build(instance_name) + instance_interface = builder.build_instance(sig.name, with_initialize: true) instance_args = instance_interface.params.map {|var| AST::Types::Var.fresh(var) } - module_name = TypeName::Class.new(name: sig.name, constructor: nil) - module_interface = builder.build(module_name) + module_interface = builder.build_class(sig.name, constructor: true) module_args = module_interface.params.map {|var| AST::Types::Var.fresh(var) } - instance_type = AST::Types::Name.new_instance(name: sig.name, args: instance_args) - module_type = AST::Types::Name.new_class(name: sig.name, args: module_args, constructor: nil) + instance_type = AST::Types::Name::Instance.new(name: sig.name, args: instance_args) + module_type = AST::Types::Name::Class.new(name: sig.name, constructor: true) stdout.puts "👀 Validating instance methods..." if verbose instance_interface.instantiate(type: instance_type, args: instance_args, instance_type: instance_type, @@ -92,10 +87,10 @@ exn.result.trace.each do |s, t| case s when Interface::Method stdout.puts " #{s.name}(#{s.type_name}) <: #{t.name}(#{t.type_name})" when Interface::MethodType - stdout.puts " #{s.location.source} <: #{t.location.source} (#{s.location.name}:#{s.location.start_line})" + stdout.puts " #{s} <: #{t} (#{s.location&.name||"?"}:#{s.location&.start_line||"?"})" else stdout.puts " #{s} <: #{t}" end end stdout.puts " 🚨 #{exn.result.error.message}"