steep 1.8.0.dev.2 → 1.8.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/bin/mem_graph.rb +67 -0
  4. data/bin/mem_prof.rb +102 -0
  5. data/bin/stackprof_test.rb +19 -0
  6. data/bin/steep-check.rb +251 -0
  7. data/lib/steep/annotation_parser.rb +1 -1
  8. data/lib/steep/ast/builtin.rb +5 -5
  9. data/lib/steep/ast/node/type_application.rb +7 -6
  10. data/lib/steep/ast/types/any.rb +1 -9
  11. data/lib/steep/ast/types/boolean.rb +8 -16
  12. data/lib/steep/ast/types/bot.rb +2 -10
  13. data/lib/steep/ast/types/class.rb +1 -13
  14. data/lib/steep/ast/types/factory.rb +101 -85
  15. data/lib/steep/ast/types/instance.rb +1 -13
  16. data/lib/steep/ast/types/intersection.rb +8 -15
  17. data/lib/steep/ast/types/literal.rb +2 -8
  18. data/lib/steep/ast/types/logic.rb +3 -24
  19. data/lib/steep/ast/types/name.rb +5 -16
  20. data/lib/steep/ast/types/nil.rb +3 -12
  21. data/lib/steep/ast/types/proc.rb +4 -13
  22. data/lib/steep/ast/types/record.rb +21 -12
  23. data/lib/steep/ast/types/self.rb +1 -13
  24. data/lib/steep/ast/types/shared_instance.rb +11 -0
  25. data/lib/steep/ast/types/top.rb +1 -9
  26. data/lib/steep/ast/types/tuple.rb +4 -10
  27. data/lib/steep/ast/types/union.rb +10 -15
  28. data/lib/steep/ast/types/var.rb +4 -13
  29. data/lib/steep/ast/types/void.rb +2 -10
  30. data/lib/steep/diagnostic/ruby.rb +4 -4
  31. data/lib/steep/drivers/check.rb +11 -14
  32. data/lib/steep/drivers/checkfile.rb +8 -10
  33. data/lib/steep/drivers/stats.rb +17 -13
  34. data/lib/steep/drivers/utils/driver_helper.rb +24 -3
  35. data/lib/steep/drivers/watch.rb +3 -3
  36. data/lib/steep/interface/builder.rb +162 -138
  37. data/lib/steep/interface/method_type.rb +12 -20
  38. data/lib/steep/interface/shape.rb +66 -10
  39. data/lib/steep/interface/substitution.rb +2 -0
  40. data/lib/steep/interface/type_param.rb +20 -7
  41. data/lib/steep/located_value.rb +20 -0
  42. data/lib/steep/server/change_buffer.rb +5 -7
  43. data/lib/steep/server/custom_methods.rb +61 -0
  44. data/lib/steep/server/delay_queue.rb +8 -1
  45. data/lib/steep/server/interaction_worker.rb +10 -5
  46. data/lib/steep/server/lsp_formatter.rb +8 -6
  47. data/lib/steep/server/master.rb +193 -140
  48. data/lib/steep/server/type_check_worker.rb +18 -19
  49. data/lib/steep/server/work_done_progress.rb +64 -0
  50. data/lib/steep/services/completion_provider.rb +24 -22
  51. data/lib/steep/services/goto_service.rb +3 -2
  52. data/lib/steep/services/hover_provider/ruby.rb +7 -6
  53. data/lib/steep/services/signature_help_provider.rb +7 -6
  54. data/lib/steep/services/signature_service.rb +1 -1
  55. data/lib/steep/services/type_check_service.rb +3 -3
  56. data/lib/steep/signature/validator.rb +17 -20
  57. data/lib/steep/subtyping/check.rb +105 -55
  58. data/lib/steep/subtyping/constraints.rb +11 -15
  59. data/lib/steep/type_construction.rb +100 -100
  60. data/lib/steep/type_inference/block_params.rb +6 -6
  61. data/lib/steep/type_inference/logic_type_interpreter.rb +11 -7
  62. data/lib/steep/type_inference/method_call.rb +3 -3
  63. data/lib/steep/type_inference/method_params.rb +1 -1
  64. data/lib/steep/type_inference/send_args.rb +1 -1
  65. data/lib/steep/typing.rb +158 -102
  66. data/lib/steep/version.rb +1 -1
  67. data/lib/steep.rb +28 -3
  68. data/steep.gemspec +2 -2
  69. metadata +16 -9
  70. data/lib/steep/type_inference/context_array.rb +0 -112
@@ -277,15 +277,14 @@ module Steep
277
277
 
278
278
  definition.methods.each do |name, method|
279
279
  Steep.logger.tagged "method = #{type_name}.#{name}" do
280
- shape.methods[name] = Interface::Shape::Entry.new(
281
- private_method: method.private?,
282
- method_types: method.defs.map do |type_def|
283
- method_name = method_name_for(type_def, name)
284
- decl = TypeInference::MethodCall::MethodDecl.new(method_name: method_name, method_def: type_def)
285
- method_type = factory.method_type(type_def.type, method_decls: Set[decl])
286
- replace_primitive_method(method_name, type_def, method_type)
287
- end
288
- )
280
+ overloads = method.defs.map do |type_def|
281
+ method_name = method_name_for(type_def, name)
282
+ method_type = factory.method_type(type_def.type)
283
+ method_type = replace_primitive_method(method_name, type_def, method_type)
284
+ Shape::MethodOverload.new(method_type, [type_def])
285
+ end
286
+
287
+ shape.methods[name] = Interface::Shape::Entry.new(method_name: name, private_method: method.private?, overloads: overloads)
289
288
  end
290
289
  end
291
290
 
@@ -308,15 +307,14 @@ module Steep
308
307
 
309
308
  definition.methods.each do |name, method|
310
309
  Steep.logger.tagged "method = #{type_name}##{name}" do
311
- shape.methods[name] = Interface::Shape::Entry.new(
312
- private_method: method.private?,
313
- method_types: method.defs.map do |type_def|
314
- method_name = method_name_for(type_def, name)
315
- decl = TypeInference::MethodCall::MethodDecl.new(method_name: method_name, method_def: type_def)
316
- method_type = factory.method_type(type_def.type, method_decls: Set[decl])
317
- replace_primitive_method(method_name, type_def, method_type)
318
- end
319
- )
310
+ overloads = method.defs.map do |type_def|
311
+ method_name = method_name_for(type_def, name)
312
+ method_type = factory.method_type(type_def.type)
313
+ method_type = replace_primitive_method(method_name, type_def, method_type)
314
+ Shape::MethodOverload.new(method_type, [type_def])
315
+ end
316
+
317
+ shape.methods[name] = Interface::Shape::Entry.new(method_name: name, private_method: method.private?, overloads: overloads)
320
318
  end
321
319
  end
322
320
 
@@ -334,51 +332,49 @@ module Steep
334
332
 
335
333
  shape = Interface::Shape.new(type: shape_type, private: true)
336
334
  all_common_methods.each do |method_name|
337
- method_typess = [] #: Array[Array[MethodType]]
335
+ overloadss = [] #: Array[Array[Shape::MethodOverload]]
338
336
  private_method = false
339
337
  shapes.each do |shape|
340
338
  entry = shape.methods[method_name] || raise
341
- method_typess << entry.method_types
339
+ overloadss << entry.overloads
342
340
  private_method ||= entry.private_method?
343
341
  end
344
342
 
345
- shape.methods[method_name] = Interface::Shape::Entry.new(private_method: private_method) do
346
- method_typess.inject do |types1, types2|
343
+ shape.methods[method_name] = Interface::Shape::Entry.new(method_name: method_name, private_method: private_method) do
344
+ overloadss.inject do |overloads1, overloads2|
347
345
  # @type break: nil
348
346
 
349
- if types1 == types2
350
- decl_array1 = types1.map(&:method_decls)
351
- decl_array2 = types2.map(&:method_decls)
352
-
353
- if decl_array1 == decl_array2
354
- next types1
355
- end
347
+ types1 = overloads1.map(&:method_type)
348
+ types2 = overloads2.map(&:method_type)
356
349
 
357
- decls1 = decl_array1.each.with_object(Set[]) {|array, decls| decls.merge(array) } #$ Set[TypeInference::MethodCall::MethodDecl]
358
- decls2 = decl_array2.each.with_object(Set[]) {|array, decls| decls.merge(array) } #$ Set[TypeInference::MethodCall::MethodDecl]
350
+ if types1 == types2
351
+ defs1 = overloads1.flat_map(&:method_defs)
352
+ defs2 = overloads2.flat_map(&:method_defs)
359
353
 
360
- if decls1 == decls2
361
- next types1
354
+ if defs1 == defs2
355
+ next overloads1
362
356
  end
363
357
  end
364
358
 
365
- method_types = {} #: Hash[MethodType, bool]
359
+ method_overloads = {} #: Hash[Shape::MethodOverload, bool]
366
360
 
367
- types1.each do |type1|
368
- types2.each do |type2|
369
- if type1 == type2
370
- method_types[type1.with(method_decls: type1.method_decls + type2.method_decls)] = true
361
+ overloads1.each do |overload1|
362
+ overloads2.each do |overload2|
363
+ if overload1.method_type == overload2.method_type
364
+ overload = Shape::MethodOverload.new(overload1.method_type, overload1.method_defs + overload2.method_defs)
365
+ method_overloads[overload] = true
371
366
  else
372
- if type = MethodType.union(type1, type2, subtyping)
373
- method_types[type] = true
367
+ if type = MethodType.union(overload1.method_type, overload2.method_type, subtyping)
368
+ overload = Shape::MethodOverload.new(type, overload1.method_defs + overload2.method_defs)
369
+ method_overloads[overload] = true
374
370
  end
375
371
  end
376
372
  end
377
373
  end
378
374
 
379
- break nil if method_types.empty?
375
+ break nil if method_overloads.empty?
380
376
 
381
- method_types.keys
377
+ method_overloads.keys
382
378
  end
383
379
  end
384
380
  end
@@ -427,7 +423,7 @@ module Steep
427
423
  end
428
424
 
429
425
  def tuple_shape(tuple)
430
- element_type = AST::Types::Union.build(types: tuple.types, location: nil)
426
+ element_type = AST::Types::Union.build(types: tuple.types)
431
427
  array_type = AST::Builtin::Array.instance_type(element_type)
432
428
 
433
429
  array_shape = yield(array_type) or raise
@@ -438,19 +434,22 @@ module Steep
438
434
  raise unless aref
439
435
 
440
436
  Shape::Entry.new(
437
+ method_name: :[],
441
438
  private_method: false,
442
- method_types: tuple.types.map.with_index {|elem_type, index|
443
- MethodType.new(
444
- type_params: [],
445
- type: Function.new(
446
- params: Function::Params.build(required: [AST::Types::Literal.new(value: index)]),
447
- return_type: elem_type,
448
- location: nil
439
+ overloads: tuple.types.map.with_index {|elem_type, index|
440
+ Shape::MethodOverload.new(
441
+ MethodType.new(
442
+ type_params: [],
443
+ type: Function.new(
444
+ params: Function::Params.build(required: [AST::Types::Literal.new(value: index)]),
445
+ return_type: elem_type,
446
+ location: nil
447
+ ),
448
+ block: nil
449
449
  ),
450
- block: nil,
451
- method_decls: Set[]
450
+ []
452
451
  )
453
- } + aref.method_types
452
+ } + aref.overloads
454
453
  )
455
454
  end
456
455
 
@@ -458,19 +457,22 @@ module Steep
458
457
  raise unless update
459
458
 
460
459
  Shape::Entry.new(
460
+ method_name: :[]=,
461
461
  private_method: false,
462
- method_types: tuple.types.map.with_index {|elem_type, index|
463
- MethodType.new(
464
- type_params: [],
465
- type: Function.new(
466
- params: Function::Params.build(required: [AST::Types::Literal.new(value: index), elem_type]),
467
- return_type: elem_type,
468
- location: nil
462
+ overloads: tuple.types.map.with_index {|elem_type, index|
463
+ Shape::MethodOverload.new(
464
+ MethodType.new(
465
+ type_params: [],
466
+ type: Function.new(
467
+ params: Function::Params.build(required: [AST::Types::Literal.new(value: index), elem_type]),
468
+ return_type: elem_type,
469
+ location: nil
470
+ ),
471
+ block: nil
469
472
  ),
470
- block: nil,
471
- method_decls: Set[]
473
+ []
472
474
  )
473
- } + update.method_types
475
+ } + update.overloads
474
476
  )
475
477
  end
476
478
 
@@ -478,8 +480,9 @@ module Steep
478
480
  raise unless fetch
479
481
 
480
482
  Shape::Entry.new(
483
+ method_name: :fetch,
481
484
  private_method: false,
482
- method_types: tuple.types.flat_map.with_index {|elem_type, index|
485
+ overloads: tuple.types.flat_map.with_index {|elem_type, index|
483
486
  [
484
487
  MethodType.new(
485
488
  type_params: [],
@@ -488,11 +491,10 @@ module Steep
488
491
  return_type: elem_type,
489
492
  location: nil
490
493
  ),
491
- block: nil,
492
- method_decls: Set[]
494
+ block: nil
493
495
  ),
494
496
  MethodType.new(
495
- type_params: [TypeParam.new(name: :T, upper_bound: nil, variance: :invariant, unchecked: false)],
497
+ type_params: [TypeParam.new(name: :T, upper_bound: nil, variance: :invariant, unchecked: false, default_type: nil)],
496
498
  type: Function.new(
497
499
  params: Function::Params.build(
498
500
  required: [
@@ -503,11 +505,10 @@ module Steep
503
505
  return_type: AST::Types::Union.build(types: [elem_type, AST::Types::Var.new(name: :T)]),
504
506
  location: nil
505
507
  ),
506
- block: nil,
507
- method_decls: Set[]
508
+ block: nil
508
509
  ),
509
510
  MethodType.new(
510
- type_params: [TypeParam.new(name: :T, upper_bound: nil, variance: :invariant, unchecked: false)],
511
+ type_params: [TypeParam.new(name: :T, upper_bound: nil, variance: :invariant, unchecked: false, default_type: nil)],
511
512
  type: Function.new(
512
513
  params: Function::Params.build(required: [AST::Types::Literal.new(value: index)]),
513
514
  return_type: AST::Types::Union.build(types: [elem_type, AST::Types::Var.new(name: :T)]),
@@ -521,27 +522,29 @@ module Steep
521
522
  ),
522
523
  optional: false,
523
524
  self_type: nil
524
- ),
525
- method_decls: Set[]
525
+ )
526
526
  )
527
- ]
528
- } + fetch.method_types
527
+ ].map { Shape::MethodOverload.new(_1, []) }
528
+ } + fetch.overloads
529
529
  )
530
530
  end
531
531
 
532
532
  first_entry = array_shape.methods[:first].yield_self do |first|
533
533
  Shape::Entry.new(
534
+ method_name: :first,
534
535
  private_method: false,
535
- method_types: [
536
- MethodType.new(
537
- type_params: [],
538
- type: Function.new(
539
- params: Function::Params.empty,
540
- return_type: tuple.types[0] || AST::Builtin.nil_type,
541
- location: nil
536
+ overloads: [
537
+ Shape::MethodOverload.new(
538
+ MethodType.new(
539
+ type_params: [],
540
+ type: Function.new(
541
+ params: Function::Params.empty,
542
+ return_type: tuple.types[0] || AST::Builtin.nil_type,
543
+ location: nil
544
+ ),
545
+ block: nil
542
546
  ),
543
- block: nil,
544
- method_decls: Set[]
547
+ []
545
548
  )
546
549
  ]
547
550
  )
@@ -549,17 +552,20 @@ module Steep
549
552
 
550
553
  last_entry = array_shape.methods[:last].yield_self do |last|
551
554
  Shape::Entry.new(
555
+ method_name: :last,
552
556
  private_method: false,
553
- method_types: [
554
- MethodType.new(
555
- type_params: [],
556
- type: Function.new(
557
- params: Function::Params.empty,
558
- return_type: tuple.types.last || AST::Builtin.nil_type,
559
- location: nil
557
+ overloads: [
558
+ Shape::MethodOverload.new(
559
+ MethodType.new(
560
+ type_params: [],
561
+ type: Function.new(
562
+ params: Function::Params.empty,
563
+ return_type: tuple.types.last || AST::Builtin.nil_type,
564
+ location: nil
565
+ ),
566
+ block: nil
560
567
  ),
561
- block: nil,
562
- method_decls: Set[]
568
+ []
563
569
  )
564
570
  ]
565
571
  )
@@ -576,10 +582,9 @@ module Steep
576
582
 
577
583
  def record_shape(record)
578
584
  all_key_type = AST::Types::Union.build(
579
- types: record.elements.each_key.map {|value| AST::Types::Literal.new(value: value, location: nil) },
580
- location: nil
585
+ types: record.elements.each_key.map {|value| AST::Types::Literal.new(value: value) }
581
586
  )
582
- all_value_type = AST::Types::Union.build(types: record.elements.values, location: nil)
587
+ all_value_type = AST::Types::Union.build(types: record.elements.values)
583
588
  hash_type = AST::Builtin::Hash.instance_type(all_key_type, all_value_type)
584
589
 
585
590
  hash_shape = yield(hash_type) or raise
@@ -589,21 +594,28 @@ module Steep
589
594
  shape.methods[:[]] = hash_shape.methods[:[]].yield_self do |aref|
590
595
  aref or raise
591
596
  Shape::Entry.new(
597
+ method_name: :[],
592
598
  private_method: false,
593
- method_types: record.elements.map do |key_value, value_type|
594
- key_type = AST::Types::Literal.new(value: key_value, location: nil)
595
-
596
- MethodType.new(
597
- type_params: [],
598
- type: Function.new(
599
- params: Function::Params.build(required: [key_type]),
600
- return_type: value_type,
601
- location: nil
599
+ overloads: record.elements.map do |key_value, value_type|
600
+ key_type = AST::Types::Literal.new(value: key_value)
601
+
602
+ if record.optional?(key_value)
603
+ value_type = AST::Builtin.optional(value_type)
604
+ end
605
+
606
+ Shape::MethodOverload.new(
607
+ MethodType.new(
608
+ type_params: [],
609
+ type: Function.new(
610
+ params: Function::Params.build(required: [key_type]),
611
+ return_type: value_type,
612
+ location: nil
613
+ ),
614
+ block: nil
602
615
  ),
603
- block: nil,
604
- method_decls: Set[]
616
+ []
605
617
  )
606
- end + aref.method_types
618
+ end + aref.overloads
607
619
  )
608
620
  end
609
621
 
@@ -611,19 +623,22 @@ module Steep
611
623
  update or raise
612
624
 
613
625
  Shape::Entry.new(
626
+ method_name: :[]=,
614
627
  private_method: false,
615
- method_types: record.elements.map do |key_value, value_type|
616
- key_type = AST::Types::Literal.new(value: key_value, location: nil)
617
- MethodType.new(
618
- type_params: [],
619
- type: Function.new(
620
- params: Function::Params.build(required: [key_type, value_type]),
621
- return_type: value_type,
622
- location: nil),
623
- block: nil,
624
- method_decls: Set[]
628
+ overloads: record.elements.map do |key_value, value_type|
629
+ key_type = AST::Types::Literal.new(value: key_value)
630
+ Shape::MethodOverload.new(
631
+ MethodType.new(
632
+ type_params: [],
633
+ type: Function.new(
634
+ params: Function::Params.build(required: [key_type, value_type]),
635
+ return_type: value_type,
636
+ location: nil),
637
+ block: nil
638
+ ),
639
+ []
625
640
  )
626
- end + update.method_types
641
+ end + update.overloads
627
642
  )
628
643
  end
629
644
 
@@ -631,9 +646,10 @@ module Steep
631
646
  update or raise
632
647
 
633
648
  Shape::Entry.new(
649
+ method_name: :fetch,
634
650
  private_method: false,
635
- method_types: record.elements.flat_map {|key_value, value_type|
636
- key_type = AST::Types::Literal.new(value: key_value, location: nil)
651
+ overloads: record.elements.flat_map {|key_value, value_type|
652
+ key_type = AST::Types::Literal.new(value: key_value)
637
653
 
638
654
  [
639
655
  MethodType.new(
@@ -643,21 +659,19 @@ module Steep
643
659
  return_type: value_type,
644
660
  location: nil
645
661
  ),
646
- block: nil,
647
- method_decls: Set[]
662
+ block: nil
648
663
  ),
649
664
  MethodType.new(
650
- type_params: [TypeParam.new(name: :T, upper_bound: nil, variance: :invariant, unchecked: false)],
665
+ type_params: [TypeParam.new(name: :T, upper_bound: nil, variance: :invariant, unchecked: false, default_type: nil)],
651
666
  type: Function.new(
652
667
  params: Function::Params.build(required: [key_type, AST::Types::Var.new(name: :T)]),
653
668
  return_type: AST::Types::Union.build(types: [value_type, AST::Types::Var.new(name: :T)]),
654
669
  location: nil
655
670
  ),
656
- block: nil,
657
- method_decls: Set[]
671
+ block: nil
658
672
  ),
659
673
  MethodType.new(
660
- type_params: [TypeParam.new(name: :T, upper_bound: nil, variance: :invariant, unchecked: false)],
674
+ type_params: [TypeParam.new(name: :T, upper_bound: nil, variance: :invariant, unchecked: false, default_type: nil)],
661
675
  type: Function.new(
662
676
  params: Function::Params.build(required: [key_type]),
663
677
  return_type: AST::Types::Union.build(types: [value_type, AST::Types::Var.new(name: :T)]),
@@ -671,11 +685,10 @@ module Steep
671
685
  ),
672
686
  optional: false,
673
687
  self_type: nil
674
- ),
675
- method_decls: Set[]
688
+ )
676
689
  )
677
- ]
678
- } + update.method_types
690
+ ].map { Shape::MethodOverload.new(_1, []) }
691
+ } + update.overloads
679
692
  )
680
693
  end
681
694
 
@@ -686,9 +699,20 @@ module Steep
686
699
  shape = Shape.new(type: proc, private: true)
687
700
  shape.methods.merge!(proc_shape.methods)
688
701
 
689
- shape.methods[:[]] = shape.methods[:call] = Shape::Entry.new(
702
+ overload = Shape::MethodOverload.new(
703
+ MethodType.new(type_params: [], type: proc.type, block: proc.block),
704
+ []
705
+ )
706
+
707
+ shape.methods[:[]] = Shape::Entry.new(
708
+ method_name: :[],
709
+ private_method: false,
710
+ overloads: [overload]
711
+ )
712
+ shape.methods[:call] = Shape::Entry.new(
713
+ method_name: :call,
690
714
  private_method: false,
691
- method_types: [MethodType.new(type_params: [], type: proc.type, block: proc.block, method_decls: Set[])]
715
+ overloads: [overload]
692
716
  )
693
717
 
694
718
  shape
@@ -707,7 +731,7 @@ module Steep
707
731
  if member.instance?
708
732
  return method_type.with(
709
733
  type: method_type.type.with(
710
- return_type: AST::Types::Logic::ReceiverIsArg.new(location: method_type.type.return_type.location)
734
+ return_type: AST::Types::Logic::ReceiverIsArg.instance()
711
735
  )
712
736
  )
713
737
  end
@@ -721,7 +745,7 @@ module Steep
721
745
  if member.instance?
722
746
  return method_type.with(
723
747
  type: method_type.type.with(
724
- return_type: AST::Types::Logic::ReceiverIsNil.new(location: method_type.type.return_type.location)
748
+ return_type: AST::Types::Logic::ReceiverIsNil.instance()
725
749
  )
726
750
  )
727
751
  end
@@ -735,7 +759,7 @@ module Steep
735
759
  AST::Builtin::NilClass.module_name
736
760
  return method_type.with(
737
761
  type: method_type.type.with(
738
- return_type: AST::Types::Logic::Not.new(location: method_type.type.return_type.location)
762
+ return_type: AST::Types::Logic::Not.instance()
739
763
  )
740
764
  )
741
765
  end
@@ -745,7 +769,7 @@ module Steep
745
769
  when RBS::BuiltinNames::Module.name
746
770
  return method_type.with(
747
771
  type: method_type.type.with(
748
- return_type: AST::Types::Logic::ArgIsReceiver.new(location: method_type.type.return_type.location)
772
+ return_type: AST::Types::Logic::ArgIsReceiver.instance()
749
773
  )
750
774
  )
751
775
  when RBS::BuiltinNames::Object.name,
@@ -759,7 +783,7 @@ module Steep
759
783
  # Value based type-case works on literal types which is available for String, Integer, Symbol, TrueClass, FalseClass, and NilClass
760
784
  return method_type.with(
761
785
  type: method_type.type.with(
762
- return_type: AST::Types::Logic::ArgEqualsReceiver.new(location: method_type.type.return_type.location)
786
+ return_type: AST::Types::Logic::ArgEqualsReceiver.instance()
763
787
  )
764
788
  )
765
789
  end
@@ -768,7 +792,7 @@ module Steep
768
792
  when RBS::BuiltinNames::Module.name
769
793
  return method_type.with(
770
794
  type: method_type.type.with(
771
- return_type: AST::Types::Logic::ArgIsAncestor.new(location: method_type.type.return_type.location)
795
+ return_type: AST::Types::Logic::ArgIsAncestor.instance()
772
796
  )
773
797
  )
774
798
  end
@@ -4,13 +4,11 @@ module Steep
4
4
  attr_reader :type_params
5
5
  attr_reader :type
6
6
  attr_reader :block
7
- attr_reader :method_decls
8
7
 
9
- def initialize(type_params:, type:, block:, method_decls:)
8
+ def initialize(type_params:, type:, block:)
10
9
  @type_params = type_params
11
10
  @type = type
12
11
  @block = block
13
- @method_decls = method_decls
14
12
  end
15
13
 
16
14
  def ==(other)
@@ -52,7 +50,7 @@ module Steep
52
50
  if ty == type && bl == block
53
51
  self
54
52
  else
55
- self.class.new(type_params: type_params, type: ty, block: bl, method_decls: method_decls)
53
+ self.class.new(type_params: type_params, type: ty, block: bl)
56
54
  end
57
55
  end
58
56
 
@@ -72,15 +70,13 @@ module Steep
72
70
  def instantiate(s)
73
71
  self.class.new(type_params: [],
74
72
  type: type.subst(s),
75
- block: block&.subst(s),
76
- method_decls: method_decls)
73
+ block: block&.subst(s))
77
74
  end
78
75
 
79
- def with(type_params: self.type_params, type: self.type, block: self.block, method_decls: self.method_decls)
76
+ def with(type_params: self.type_params, type: self.type, block: self.block)
80
77
  self.class.new(type_params: type_params,
81
78
  type: type,
82
- block: block,
83
- method_decls: method_decls)
79
+ block: block)
84
80
  end
85
81
 
86
82
  def to_s
@@ -95,8 +91,7 @@ module Steep
95
91
  def map_type(&block)
96
92
  self.class.new(type_params: type_params,
97
93
  type: type.map_type(&block),
98
- block: self.block&.yield_self {|blk| blk.map_type(&block) },
99
- method_decls: method_decls)
94
+ block: self.block&.yield_self {|blk| blk.map_type(&block) })
100
95
  end
101
96
 
102
97
  # Returns a new method type which can be used for the method implementation type of both `self` and `other`.
@@ -125,8 +120,7 @@ module Steep
125
120
  ),
126
121
  location: nil
127
122
  ),
128
- block: block,
129
- method_decls: method_decls + other.method_decls
123
+ block: block
130
124
  )
131
125
  end
132
126
 
@@ -245,7 +239,7 @@ module Steep
245
239
  when (self_self = b.self_type) && (other_self = ob.self_type)
246
240
  AST::Types::Union.build(types: [self_self, other_self])
247
241
  when b.self_type || ob.self_type
248
- AST::Types::Bot.new()
242
+ AST::Types::Bot.instance
249
243
  else
250
244
  nil
251
245
  end
@@ -280,8 +274,7 @@ module Steep
280
274
  MethodType.new(
281
275
  type_params: [],
282
276
  type: Function.new(params: params, return_type: return_type, location: nil),
283
- block: block,
284
- method_decls: method_decls + other.method_decls
277
+ block: block
285
278
  )
286
279
  end
287
280
 
@@ -293,7 +286,7 @@ module Steep
293
286
  else
294
287
  params = self.type.params || other.type.params
295
288
  end
296
-
289
+
297
290
  block =
298
291
  case
299
292
  when (b = self.block) && (ob = other.block)
@@ -302,7 +295,7 @@ module Steep
302
295
  when (self_self = b.self_type) && (other_self = ob.self_type)
303
296
  AST::Types::Intersection.build(types: [self_self, other_self])
304
297
  when b.self_type || ob.self_type
305
- AST::Types::Top.new()
298
+ AST::Types::Top.instance
306
299
  else
307
300
  nil
308
301
  end
@@ -324,8 +317,7 @@ module Steep
324
317
  MethodType.new(
325
318
  type_params: [],
326
319
  type: Function.new(params: params, return_type: return_type, location: nil),
327
- block: block,
328
- method_decls: method_decls + other.method_decls
320
+ block: block
329
321
  )
330
322
  end
331
323
  end