steep 1.1.1 → 1.2.0.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/Gemfile +0 -1
  4. data/Gemfile.lock +12 -11
  5. data/Gemfile.steep +1 -1
  6. data/Gemfile.steep.lock +9 -9
  7. data/README.md +3 -3
  8. data/Steepfile +23 -0
  9. data/bin/steep-prof +2 -1
  10. data/lib/steep/annotation_parser.rb +1 -1
  11. data/lib/steep/ast/types/class.rb +4 -0
  12. data/lib/steep/ast/types/factory.rb +86 -602
  13. data/lib/steep/ast/types/instance.rb +4 -0
  14. data/lib/steep/ast/types/literal.rb +1 -1
  15. data/lib/steep/ast/types/proc.rb +22 -8
  16. data/lib/steep/ast/types/self.rb +4 -0
  17. data/lib/steep/ast/types/union.rb +1 -1
  18. data/lib/steep/cli.rb +24 -1
  19. data/lib/steep/diagnostic/ruby.rb +17 -22
  20. data/lib/steep/drivers/checkfile.rb +205 -0
  21. data/lib/steep/drivers/validate.rb +3 -1
  22. data/lib/steep/equatable.rb +2 -0
  23. data/lib/steep/interface/block.rb +21 -11
  24. data/lib/steep/interface/builder.rb +756 -0
  25. data/lib/steep/interface/function.rb +32 -24
  26. data/lib/steep/interface/method_type.rb +191 -78
  27. data/lib/steep/interface/shape.rb +132 -0
  28. data/lib/steep/interface/substitution.rb +23 -12
  29. data/lib/steep/interface/type_param.rb +1 -2
  30. data/lib/steep/path_helper.rb +1 -1
  31. data/lib/steep/project.rb +5 -7
  32. data/lib/steep/server/base_worker.rb +2 -2
  33. data/lib/steep/server/change_buffer.rb +4 -3
  34. data/lib/steep/server/interaction_worker.rb +1 -1
  35. data/lib/steep/server/master.rb +69 -9
  36. data/lib/steep/server/type_check_worker.rb +13 -11
  37. data/lib/steep/server/worker_process.rb +9 -7
  38. data/lib/steep/services/completion_provider.rb +15 -3
  39. data/lib/steep/services/hover_provider/singleton_methods.rb +5 -6
  40. data/lib/steep/services/signature_service.rb +13 -8
  41. data/lib/steep/services/type_check_service.rb +2 -0
  42. data/lib/steep/signature/validator.rb +1 -1
  43. data/lib/steep/subtyping/check.rb +154 -103
  44. data/lib/steep/subtyping/relation.rb +3 -3
  45. data/lib/steep/subtyping/result.rb +20 -2
  46. data/lib/steep/subtyping/variable_variance.rb +9 -0
  47. data/lib/steep/type_construction.rb +558 -299
  48. data/lib/steep/type_inference/block_params.rb +169 -86
  49. data/lib/steep/type_inference/logic_type_interpreter.rb +9 -14
  50. data/lib/steep/type_inference/method_params.rb +12 -7
  51. data/lib/steep/type_inference/send_args.rb +41 -35
  52. data/lib/steep/type_inference/type_env_builder.rb +1 -1
  53. data/lib/steep/version.rb +1 -1
  54. data/lib/steep.rb +71 -2
  55. data/rbs_collection.steep.lock.yaml +18 -30
  56. data/rbs_collection.steep.yaml +1 -0
  57. data/sig/shims/language-server_protocol.rbs +20 -0
  58. data/sig/shims/tagged_logging.rbs +6 -0
  59. data/sig/steep/ast/annotation/collection.rbs +6 -6
  60. data/sig/steep/ast/types/class.rbs +3 -0
  61. data/sig/steep/ast/types/factory.rbs +38 -32
  62. data/sig/steep/ast/types/instance.rbs +3 -0
  63. data/sig/steep/ast/types/intersection.rbs +1 -1
  64. data/sig/steep/ast/types/literal.rbs +7 -7
  65. data/sig/steep/ast/types/name.rbs +14 -13
  66. data/sig/steep/ast/types/proc.rbs +3 -1
  67. data/sig/steep/ast/types/self.rbs +3 -0
  68. data/sig/steep/ast/types/var.rbs +1 -1
  69. data/sig/steep/diagnostic/ruby.rbs +30 -34
  70. data/sig/steep/drivers/annotations.rbs +17 -0
  71. data/sig/steep/drivers/check.rbs +33 -0
  72. data/sig/steep/drivers/checkfile.rbs +26 -0
  73. data/sig/steep/drivers/diagnostic_printer.rbs +25 -0
  74. data/sig/steep/drivers/init.rbs +19 -0
  75. data/sig/steep/drivers/langserver.rbs +35 -0
  76. data/sig/steep/drivers/print_project.rbs +15 -0
  77. data/sig/steep/drivers/stats.rbs +37 -0
  78. data/sig/steep/drivers/utils/driver_helper.rbs +23 -0
  79. data/sig/steep/drivers/utils/jobs_count.rbs +11 -0
  80. data/sig/steep/drivers/validate.rbs +15 -0
  81. data/sig/steep/drivers/vendor.rbs +19 -0
  82. data/sig/steep/drivers/watch.rbs +27 -0
  83. data/sig/steep/drivers/worker.rbs +31 -0
  84. data/sig/steep/equatable.rbs +11 -0
  85. data/sig/steep/index/rbs_index.rbs +91 -0
  86. data/sig/steep/index/signature_symbol_provider.rbs +29 -0
  87. data/sig/steep/index/source_index.rbs +63 -0
  88. data/sig/steep/interface/block.rbs +3 -1
  89. data/sig/steep/interface/builder.rbs +152 -0
  90. data/sig/steep/interface/function.rbs +67 -55
  91. data/sig/steep/interface/method_type.rbs +60 -12
  92. data/sig/steep/interface/shape.rbs +61 -0
  93. data/sig/steep/interface/substitution.rbs +18 -22
  94. data/sig/steep/interface/type_param.rbs +9 -1
  95. data/sig/steep/path_helper.rbs +7 -0
  96. data/sig/steep/project/pattern.rbs +10 -10
  97. data/sig/steep/project/target.rbs +2 -2
  98. data/sig/steep/project.rbs +15 -8
  99. data/sig/steep/server/base_worker.rbs +49 -0
  100. data/sig/steep/server/change_buffer.rbs +32 -0
  101. data/sig/steep/server/interaction_worker.rbs +41 -0
  102. data/sig/steep/server/lsp_formatter.rbs +29 -0
  103. data/sig/steep/server/master.rbs +260 -0
  104. data/sig/steep/server/type_check_worker.rbs +135 -0
  105. data/sig/steep/server/worker_process.rbs +29 -0
  106. data/sig/steep/services/completion_provider.rbs +5 -5
  107. data/sig/steep/services/content_change.rbs +14 -12
  108. data/sig/steep/services/file_loader.rbs +12 -4
  109. data/sig/steep/services/hover_provider/singleton_methods.rbs +1 -1
  110. data/sig/steep/services/path_assignment.rbs +7 -7
  111. data/sig/steep/services/signature_service.rbs +67 -40
  112. data/sig/steep/services/type_check_service.rbs +53 -39
  113. data/sig/steep/subtyping/check.rbs +80 -44
  114. data/sig/steep/subtyping/relation.rbs +24 -22
  115. data/sig/steep/subtyping/result.rbs +48 -30
  116. data/sig/steep/subtyping/variable_variance.rbs +2 -0
  117. data/sig/steep/type_construction.rbs +132 -23
  118. data/sig/steep/type_inference/block_params.rbs +120 -18
  119. data/sig/steep/type_inference/context.rbs +45 -20
  120. data/sig/steep/type_inference/context_array.rbs +37 -0
  121. data/sig/steep/type_inference/logic_type_interpreter.rbs +3 -1
  122. data/sig/steep/type_inference/method_params.rbs +13 -9
  123. data/sig/steep/type_inference/send_args.rbs +229 -0
  124. data/sig/steep/type_inference/type_env_builder.rbs +1 -1
  125. data/sig/steep/typing.rbs +4 -4
  126. data/sig/steep.rbs +4 -2
  127. data/smoke/block/e.rb +12 -0
  128. data/smoke/block/e.rbs +4 -0
  129. data/smoke/block/test_expectations.yml +12 -0
  130. data/smoke/regression/block_param_split.rb +7 -0
  131. data/smoke/regression/block_param_split.rbs +3 -0
  132. data/smoke/regression/empty_yield.rb +5 -0
  133. data/smoke/regression/empty_yield.rbs +3 -0
  134. data/smoke/regression/test_expectations.yml +12 -0
  135. data/smoke/yield/test_expectations.yml +4 -4
  136. data/steep.gemspec +2 -1
  137. metadata +61 -9
  138. data/lib/steep/interface/interface.rb +0 -34
  139. data/sig/steep/interface/interface.rbs +0 -23
  140. data/sig/version.rbs +0 -3
@@ -2,34 +2,36 @@ module Steep
2
2
  module Services
3
3
  class ContentChange
4
4
  class Position
5
- attr_reader line: untyped
5
+ attr_reader line: Integer
6
6
 
7
- attr_reader column: untyped
7
+ attr_reader column: Integer
8
8
 
9
- def initialize: (line: untyped, column: untyped) -> void
9
+ def initialize: (line: Integer, column: Integer) -> void
10
10
 
11
- def ==: (untyped other) -> untyped
11
+ def ==: (untyped other) -> bool
12
12
 
13
13
  alias eql? ==
14
14
 
15
- def hash: () -> untyped
15
+ def hash: () -> Integer
16
16
  end
17
17
 
18
- attr_reader range: untyped
18
+ type range = [Position, Position]
19
19
 
20
- attr_reader text: untyped
20
+ attr_reader range: range?
21
21
 
22
- def initialize: (text: untyped, ?range: untyped?) -> void
22
+ attr_reader text: String
23
23
 
24
- def ==: (untyped other) -> untyped
24
+ def initialize: (text: String, ?range: range?) -> void
25
+
26
+ def ==: (untyped other) -> bool
25
27
 
26
28
  alias eql? ==
27
29
 
28
- def hash: () -> untyped
30
+ def hash: () -> Integer
29
31
 
30
- def self.string: (untyped string) -> untyped
32
+ def self.string: (String) -> ContentChange
31
33
 
32
- def apply_to: (untyped text) -> untyped
34
+ def apply_to: (String text) -> String
33
35
  end
34
36
  end
35
37
  end
@@ -1,13 +1,21 @@
1
1
  module Steep
2
2
  module Services
3
3
  class FileLoader
4
- attr_reader base_dir: untyped
4
+ attr_reader base_dir: Pathname
5
5
 
6
- def initialize: (base_dir: untyped) -> void
6
+ def initialize: (base_dir: Pathname) -> void
7
7
 
8
- def each_path_in_patterns: (untyped pattern, ?untyped commandline_patterns) { (untyped) -> untyped } -> untyped
8
+ # Yields relative paths included in `pattern` from `base_dir`
9
+ #
10
+ def each_path_in_patterns: (Project::Pattern pattern, ?Array[String] commandline_patterns) { (Pathname) -> void } -> void
11
+ | (Project::Pattern pattern, ?Array[String] commandline_patterns) -> Enumerator[Pathname, void]
9
12
 
10
- def load_changes: (untyped pattern, ?untyped command_line_patterns, changes: untyped) -> untyped
13
+ # Returns changes that represents loading files from file system merged with ones given as `changes:`
14
+ #
15
+ # ```
16
+ # changes = loader.load_changes(target.pattern, command_line_patterns, changes: changes_from_editor)
17
+ # ```
18
+ def load_changes: (Project::Pattern pattern, ?Array[String] command_line_patterns, changes: Hash[Pathname, Array[ContentChange]]) -> Hash[Pathname, Array[ContentChange]]
11
19
  end
12
20
  end
13
21
  end
@@ -2,7 +2,7 @@ module Steep
2
2
  module Services
3
3
  module HoverProvider
4
4
  module SingletonMethods
5
- def content_for: (service: untyped, path: untyped, line: untyped, column: untyped) -> untyped
5
+ def content_for: (service: TypeCheckService, path: Pathname, line: Integer, column: Integer) -> (Ruby | RBS | nil)
6
6
  end
7
7
 
8
8
  extend SingletonMethods
@@ -1,21 +1,21 @@
1
1
  module Steep
2
2
  module Services
3
3
  class PathAssignment
4
- attr_reader index: untyped
4
+ attr_reader index: Integer
5
5
 
6
- attr_reader max_index: untyped
6
+ attr_reader max_index: Integer
7
7
 
8
- attr_reader cache: untyped
8
+ attr_reader cache: Hash[Pathname, Integer]
9
9
 
10
- def initialize: (index: untyped, max_index: untyped) -> void
10
+ def initialize: (index: Integer, max_index: Integer) -> void
11
11
 
12
- def self.all: () -> untyped
12
+ def self.all: () -> PathAssignment
13
13
 
14
- def =~: (untyped path) -> untyped
14
+ def =~: (Pathname path) -> bool
15
15
 
16
16
  alias === =~
17
17
 
18
- def self.index_for: (path: untyped, max_index: untyped) -> untyped
18
+ def self.index_for: (path: String, max_index: Integer) -> Integer
19
19
  end
20
20
  end
21
21
  end
@@ -1,91 +1,118 @@
1
1
  module Steep
2
2
  module Services
3
3
  class SignatureService
4
- attr_reader status: untyped
4
+ type status = SyntaxErrorStatus | AncestorErrorStatus | LoadedStatus
5
+
6
+ attr_reader status: status
5
7
 
6
8
  class SyntaxErrorStatus
7
- attr_reader files: untyped
9
+ attr_reader files: Hash[Pathname, FileStatus]
10
+
11
+ attr_reader changed_paths: Set[Pathname]
8
12
 
9
- attr_reader changed_paths: untyped
13
+ attr_reader diagnostics: Array[Diagnostic::Signature::Base]
10
14
 
11
- attr_reader diagnostics: untyped
15
+ attr_reader last_builder: RBS::DefinitionBuilder
12
16
 
13
- attr_reader last_builder: untyped
17
+ @rbs_index: Index::RBSIndex?
14
18
 
15
- def initialize: (files: untyped, changed_paths: untyped, diagnostics: untyped, last_builder: untyped) -> void
19
+ def initialize: (files: Hash[Pathname, FileStatus], changed_paths: Set[Pathname], diagnostics: Array[Diagnostic::Signature::Base], last_builder: RBS::DefinitionBuilder) -> void
16
20
 
17
- def rbs_index: () -> untyped
21
+ def rbs_index: () -> Index::RBSIndex
18
22
  end
19
23
 
20
24
  class AncestorErrorStatus
21
- attr_reader files: untyped
25
+ attr_reader files: Hash[Pathname, FileStatus]
26
+
27
+ attr_reader changed_paths: Set[Pathname]
22
28
 
23
- attr_reader changed_paths: untyped
29
+ attr_reader diagnostics: Array[Diagnostic::Signature::Base]
24
30
 
25
- attr_reader diagnostics: untyped
31
+ attr_reader last_builder: RBS::DefinitionBuilder
26
32
 
27
- attr_reader last_builder: untyped
33
+ @rbs_index: Index::RBSIndex?
28
34
 
29
- def initialize: (files: untyped, changed_paths: untyped, diagnostics: untyped, last_builder: untyped) -> void
35
+ def initialize: (files: Hash[Pathname, FileStatus], changed_paths: Set[Pathname], diagnostics: Array[Diagnostic::Signature::Base], last_builder: RBS::DefinitionBuilder) -> void
30
36
 
31
- def rbs_index: () -> untyped
37
+ def rbs_index: () -> Index::RBSIndex
32
38
  end
33
39
 
34
40
  class LoadedStatus
35
- attr_reader files: untyped
41
+ attr_reader files: Hash[Pathname, FileStatus]
42
+
43
+ attr_reader builder: RBS::DefinitionBuilder
44
+
45
+ @rbs_index: Index::RBSIndex?
46
+
47
+ @subtyping: Subtyping::Check?
48
+
49
+ def initialize: (files: Hash[Pathname, FileStatus], builder: RBS::DefinitionBuilder) -> void
50
+
51
+ def subtyping: () -> Subtyping::Check
52
+
53
+ def rbs_index: () -> Index::RBSIndex
54
+ end
36
55
 
37
- attr_reader builder: untyped
56
+ class FileStatus
57
+ attr_reader path: Pathname
38
58
 
39
- def initialize: (files: untyped, builder: untyped) -> void
59
+ attr_reader content: String
40
60
 
41
- def subtyping: () -> untyped
61
+ attr_reader decls: Array[RBS::AST::Declarations::t] | Diagnostic::Signature::UnexpectedError | RBS::ParsingError
42
62
 
43
- def rbs_index: () -> untyped
63
+ def initialize: (
64
+ path: Pathname,
65
+ content: String,
66
+ decls: Array[RBS::AST::Declarations::t] | Diagnostic::Signature::UnexpectedError | RBS::ParsingError
67
+ ) -> void
44
68
  end
45
69
 
46
- FileStatus: untyped
70
+ def initialize: (env: RBS::Environment) -> void
47
71
 
48
- def initialize: (env: untyped) -> void
72
+ def self.load_from: (RBS::EnvironmentLoader loader) -> SignatureService
49
73
 
50
- def self.load_from: (untyped loader) -> untyped
74
+ @env_rbs_paths: Set[Pathname]?
51
75
 
52
- def env_rbs_paths: () -> untyped
76
+ def env_rbs_paths: () -> Set[Pathname]
53
77
 
54
- def each_rbs_path: () { (untyped) -> untyped } -> untyped
78
+ def each_rbs_path: () { (Pathname) -> void } -> void
79
+ | () -> Enumerator[Pathname, void]
55
80
 
56
- def files: () -> untyped
81
+ def files: () -> Hash[Pathname, FileStatus]
57
82
 
58
- def pending_changed_paths: () -> untyped
83
+ def pending_changed_paths: () -> Set[Pathname]
59
84
 
60
- def latest_env: () -> untyped
85
+ def latest_env: () -> RBS::Environment
61
86
 
62
- def latest_builder: () -> untyped
87
+ def latest_builder: () -> RBS::DefinitionBuilder
63
88
 
64
- def latest_rbs_index: () -> untyped
89
+ def latest_rbs_index: () -> Index::RBSIndex
65
90
 
66
- def current_subtyping: () -> (untyped | nil)
91
+ def current_subtyping: () -> Subtyping::Check?
67
92
 
68
- def apply_changes: (untyped files, untyped changes) -> untyped
93
+ def apply_changes: (Hash[Pathname, FileStatus] files, Server::ChangeBuffer::changes changes) -> Hash[Pathname, FileStatus]
69
94
 
70
- def update: (untyped changes) -> untyped
95
+ def update: (Server::ChangeBuffer::changes changes) -> void
71
96
 
72
- def update_env: (untyped updated_files, paths: untyped) -> untyped
97
+ def update_env: (
98
+ Hash[Pathname, FileStatus] updated_files, paths: Set[Pathname]
99
+ ) -> (RBS::DefinitionBuilder::AncestorBuilder | Array[Diagnostic::Signature::Base])
73
100
 
74
- def rescue_rbs_error: (untyped errors) { () -> untyped } -> untyped
101
+ def rescue_rbs_error: (Array[RBS::BaseError] errors) { () -> void } -> void
75
102
 
76
- def update_builder: (ancestor_builder: untyped, paths: untyped) -> untyped
103
+ def update_builder: (ancestor_builder: RBS::DefinitionBuilder::AncestorBuilder, paths: Set[Pathname]) -> RBS::DefinitionBuilder
77
104
 
78
- def type_names: (paths: untyped, env: untyped) -> untyped
105
+ def type_names: (paths: Set[Pathname], env: RBS::Environment) -> Set[RBS::TypeName]
79
106
 
80
- def const_decls: (paths: untyped, env: untyped) -> untyped
107
+ def const_decls: (paths: Set[Pathname], env: RBS::Environment) -> Hash[RBS::TypeName, RBS::Environment::SingleEntry[RBS::TypeName, RBS::AST::Declarations::Constant]]
81
108
 
82
- def global_decls: (paths: untyped, ?env: untyped) -> untyped
109
+ def global_decls: (paths: Set[Pathname], ?env: RBS::Environment) -> Hash[Symbol, RBS::Environment::SingleEntry[Symbol, RBS::AST::Declarations::Global]]
83
110
 
84
- def type_name_from_decl: (untyped decl, set: untyped) -> untyped
111
+ def type_name_from_decl: (RBS::AST::Declarations::t decl, set: Set[RBS::TypeName]) -> void
85
112
 
86
- def add_descendants: (graph: untyped, names: untyped, set: untyped) -> untyped
113
+ def add_descendants: (graph: RBS::AncestorGraph, names: Set[RBS::TypeName], set: Set[RBS::TypeName]) -> void
87
114
 
88
- def add_nested_decls: (env: untyped, names: untyped, set: untyped) -> untyped
115
+ def add_nested_decls: (env: RBS::Environment, names: Set[RBS::TypeName], set: Set[RBS::TypeName]) -> void
89
116
  end
90
117
  end
91
118
  end
@@ -1,93 +1,107 @@
1
1
  module Steep
2
2
  module Services
3
3
  class TypeCheckService
4
- attr_reader project: untyped
4
+ attr_reader project: Project
5
5
 
6
- attr_reader signature_validation_diagnostics: untyped
6
+ attr_reader signature_validation_diagnostics: Hash[Symbol, Hash[Pathname, Array[Diagnostic::Signature::Base]]]
7
7
 
8
- attr_reader source_files: untyped
8
+ attr_reader source_files: Hash[Pathname, SourceFile]
9
9
 
10
- attr_reader signature_services: untyped
10
+ attr_reader signature_services: Hash[Symbol, SignatureService]
11
11
 
12
12
  class SourceFile
13
- attr_reader path: untyped
13
+ attr_reader path: Pathname
14
14
 
15
- attr_reader target: untyped
15
+ attr_reader target: Project::Target
16
16
 
17
- attr_reader content: untyped
17
+ attr_reader content: String
18
18
 
19
- attr_reader node: untyped
19
+ attr_reader node: Parser::AST::Node | nil | false
20
20
 
21
- attr_reader typing: untyped
21
+ attr_reader typing: Typing?
22
22
 
23
- attr_reader errors: untyped
23
+ attr_reader errors: Array[Diagnostic::Ruby::Base]?
24
24
 
25
- def initialize: (path: untyped, node: untyped, content: untyped, typing: untyped, errors: untyped) -> void
25
+ def initialize: (
26
+ path: Pathname,
27
+ node: Parser::AST::Node | nil | false,
28
+ content: String,
29
+ typing: Typing?,
30
+ errors: Array[Diagnostic::Ruby::Base]?
31
+ ) -> void
26
32
 
27
- def self.with_syntax_error: (path: untyped, content: untyped, error: untyped) -> untyped
33
+ def self.with_syntax_error: (path: Pathname, content: String, error: Diagnostic::Ruby::SyntaxError) -> SourceFile
28
34
 
29
- def self.with_typing: (path: untyped, content: untyped, typing: untyped, node: untyped) -> untyped
35
+ def self.with_typing: (path: Pathname, content: String, typing: Typing, node: Parser::AST::Node?) -> SourceFile
30
36
 
31
- def self.no_data: (path: untyped, content: untyped) -> untyped
37
+ def self.no_data: (path: Pathname, content: String) -> SourceFile
32
38
 
33
- def update_content: (untyped content) -> untyped
39
+ def update_content: (String content) -> SourceFile
34
40
 
35
- def diagnostics: () -> untyped
41
+ def diagnostics: () -> Array[Diagnostic::Ruby::Base]
36
42
  end
37
43
 
38
44
  class TargetRequest
39
- attr_reader target: untyped
45
+ attr_reader target: Project::Target
40
46
 
41
- attr_reader source_paths: untyped
47
+ attr_reader source_paths: Set[Pathname]
42
48
 
43
- def initialize: (target: untyped) -> void
49
+ @signature_updated: bool
50
+
51
+ def initialize: (target: Project::Target) -> void
44
52
 
45
53
  def signature_updated!: (?bool value) -> self
46
54
 
47
- def signature_updated?: () -> untyped
55
+ def signature_updated?: () -> bool
48
56
 
49
- def empty?: () -> untyped
57
+ def empty?: () -> bool
50
58
 
51
- def ==: (untyped other) -> untyped
59
+ def ==: (untyped other) -> bool
52
60
 
53
61
  alias eql? ==
54
62
 
55
- def hash: () -> untyped
63
+ def hash: () -> Integer
56
64
  end
57
65
 
58
- def initialize: (project: untyped) -> void
66
+ def initialize: (project: Project) -> void
59
67
 
60
- def signature_diagnostics: () -> untyped
68
+ def signature_diagnostics: () -> Hash[Pathname, Array[Diagnostic::Signature::Base]]
61
69
 
62
- def has_diagnostics?: () -> untyped
70
+ def has_diagnostics?: () -> bool
63
71
 
64
- def diagnostics: () -> untyped
72
+ def diagnostics: () -> Hash[Pathname, Array[Diagnostic::Ruby::Base | Diagnostic::Signature::Base]]
65
73
 
66
- def each_diagnostics: () { (untyped) -> untyped } -> untyped
74
+ def each_diagnostics: () { ([Pathname, Array[Diagnostic::Ruby::Base] | Array[Diagnostic::Signature::Base]]) -> void } -> void
75
+ | () -> Enumerator[[Pathname, Array[Diagnostic::Ruby::Base] | Array[Diagnostic::Signature::Base]], void]
67
76
 
68
- def update: (changes: untyped) -> untyped
77
+ def update: (changes: Server::ChangeBuffer::changes) -> Hash[Project::Target, TargetRequest]
69
78
 
70
- def update_and_check: (changes: untyped, assignment: untyped) ?{ () -> untyped } -> untyped
79
+ def update_and_check: (
80
+ changes: Server::ChangeBuffer::changes,
81
+ assignment: PathAssignment
82
+ ) {
83
+ ([Pathname, Array[Diagnostic::Signature::Base] | Array[Diagnostic::Ruby::Base]]) -> void
84
+ } -> void
71
85
 
72
- def validate_signature: (path: untyped) { (untyped) -> untyped } -> untyped
86
+ def validate_signature: (path: Pathname) { ([Pathname, Array[Diagnostic::Signature::Base]]) -> void } -> void
73
87
 
74
- def typecheck_source: (path: untyped, ?target: untyped) { (untyped) -> untyped } -> (nil | untyped)
88
+ def typecheck_source: (path: Pathname, ?target: Project::Target?) { ([Pathname, Array[Diagnostic::Ruby::Base]]) -> void } -> void
75
89
 
76
- def update_signature: (changes: untyped, requests: untyped) -> untyped
90
+ def update_signature: (changes: Server::ChangeBuffer::changes, requests: Hash[Project::Target, TargetRequest]) -> void
77
91
 
78
- def update_sources: (changes: untyped, requests: untyped) -> untyped
92
+ def update_sources: (changes: Server::ChangeBuffer::changes, requests: Hash[Project::Target, TargetRequest]) -> void
79
93
 
80
- def type_check_file: (target: untyped, subtyping: untyped, path: untyped, text: untyped) -> untyped
94
+ def type_check_file: (target: Project::Target, subtyping: Subtyping::Check, path: Pathname, text: String) -> SourceFile
81
95
 
82
96
  def self.type_check: (source: Source, subtyping: Subtyping::Check) -> Typing
83
97
 
84
- def source_file?: (Pathname path) -> (untyped | nil)
98
+ def source_file?: (Pathname path) -> Project::Target?
85
99
 
86
- def signature_file?: (Pathname path) -> untyped
100
+ def signature_file?: (Pathname path) -> Array[Symbol]?
87
101
 
88
- def app_signature_file?: (Pathname path) -> untyped
102
+ def app_signature_file?: (Pathname path) -> Array[Symbol]?
89
103
 
90
- def lib_signature_file?: (Pathname path) -> untyped
104
+ def lib_signature_file?: (Pathname path) -> bool
91
105
  end
92
106
  end
93
107
  end
@@ -1,93 +1,129 @@
1
1
  module Steep
2
2
  module Subtyping
3
3
  class Check
4
- attr_reader factory: AST::Types::Factory
4
+ attr_reader builder: Interface::Builder
5
5
 
6
- attr_reader cache: untyped
6
+ attr_reader cache: Cache
7
7
 
8
- attr_reader assumptions: untyped
8
+ @assumptions: Set[Relation[untyped]]?
9
9
 
10
- def initialize: (factory: untyped) -> void
10
+ @bounds: Array[Hash[Symbol, AST::Types::t?]]
11
11
 
12
- def with_context: (self_type: untyped, instance_type: untyped, class_type: untyped, constraints: untyped) { () -> untyped } -> untyped
12
+ @self_type: AST::Types::t?
13
13
 
14
- def push_assumption: (untyped relation) { () -> untyped } -> untyped
14
+ @instance_type: AST::Types::t?
15
15
 
16
- def push_variable_bounds: (untyped params) { () -> untyped } -> untyped
16
+ @class_type: AST::Types::t?
17
17
 
18
- def variable_upper_bound: (untyped name) -> (untyped | nil)
18
+ @constraints: Constraints?
19
19
 
20
- def self_type: () -> untyped
20
+ def initialize: (builder: Interface::Builder) -> void
21
21
 
22
- def instance_type: () -> untyped
22
+ def factory: () -> AST::Types::Factory
23
23
 
24
- def class_type: () -> untyped
24
+ def with_context: [A] (self_type: AST::Types::t, instance_type: AST::Types::t, class_type: AST::Types::t, constraints: Constraints) { () -> A } -> A
25
25
 
26
- def constraints: () -> untyped
26
+ def self_type: () -> AST::Types::t
27
27
 
28
- def each_ancestor: (untyped ancestors) { (untyped) -> untyped } -> untyped
28
+ def instance_type: () -> AST::Types::t
29
29
 
30
- def instance_super_types: (untyped type_name, args: untyped) -> untyped
30
+ def class_type: () -> AST::Types::t
31
31
 
32
- def singleton_super_types: (untyped type_name) -> untyped
32
+ def constraints: () -> Constraints
33
33
 
34
- def check: (untyped relation, constraints: untyped, self_type: untyped, instance_type: untyped, class_type: untyped) -> untyped
34
+ def push_variable_bounds: [A] (Array[Interface::TypeParam] | Hash[Symbol, AST::Types::t?] params) { () -> A } -> A
35
35
 
36
- def check_type: (untyped relation) -> untyped
36
+ def variable_upper_bound: (Symbol name) -> AST::Types::t?
37
37
 
38
- def cache_bounds: (untyped relation) -> untyped
38
+ def variable_upper_bounds: () -> Hash[Symbol, AST::Types::t?]
39
39
 
40
- def alias?: (untyped `type`) -> untyped
40
+ def push_assumption: [A] (Relation[untyped] relation) { () -> A } -> A
41
41
 
42
- def cacheable?: (untyped relation) -> untyped
42
+ def assumptions: () -> Set[Relation[untyped]]
43
43
 
44
- def true_type?: (untyped `type`) -> untyped
44
+ def each_ancestor: (RBS::DefinitionBuilder::AncestorBuilder::OneAncestors ancestors) { (RBS::Definition::Ancestor::t) -> void } -> void
45
+ | (RBS::DefinitionBuilder::AncestorBuilder::OneAncestors ancestors) -> Enumerator[RBS::Definition::Ancestor::t, void]
45
46
 
46
- def false_type?: (untyped `type`) -> untyped
47
+ type super_type = AST::Types::Name::Instance | AST::Types::Name::Interface | AST::Types::Name::Singleton
48
+
49
+ def instance_super_types: (RBS::TypeName type_name, args: Array[AST::Types::t]) -> Array[super_type]
50
+
51
+ def singleton_super_types: (RBS::TypeName type_name) -> Array[super_type]
52
+
53
+ def check: (Relation[AST::Types::t] relation, constraints: Constraints, self_type: AST::Types::t, instance_type: AST::Types::t, class_type: AST::Types::t) -> Result::t
54
+
55
+ def check_type: (Relation[AST::Types::t] relation) -> Result::t
56
+
57
+ def cache_bounds: (Relation[AST::Types::t] relation) -> Hash[Symbol, AST::Types::t?]
58
+
59
+ def alias?: (AST::Types::t `type`) -> bool
60
+
61
+ def cacheable?: (Relation[AST::Types::t] relation) -> bool
62
+
63
+ def true_type?: (AST::Types::t `type`) -> bool
64
+
65
+ def false_type?: (AST::Types::t `type`) -> bool
47
66
 
48
67
  include Result::Helper
49
68
 
50
- def check_type0: (untyped relation) -> untyped
69
+ def check_type0: (Relation[AST::Types::t] relation) -> Result::t
51
70
 
52
- def definition_for_type: (untyped `type`) -> untyped
71
+ def definition_for_type: (AST::Types::t `type`) -> RBS::Definition
53
72
 
54
- def arg_type?: (untyped `type`) -> untyped
73
+ # Returns true if given `type` is with one or more type arguments.
74
+ #
75
+ def arg_type?: (AST::Types::t `type`) -> bool
55
76
 
56
- def check_type_arg: (untyped relation) -> untyped
77
+ type application_type = AST::Types::Name::Instance | AST::Types::Name::Interface | AST::Types::Name::Alias
57
78
 
58
- def same_type?: (untyped relation) -> (true | untyped)
79
+ def check_type_arg: (Relation[application_type] relation) -> untyped
59
80
 
60
- def check_interface: (untyped relation) -> untyped
81
+ def same_type?: (Relation[AST::Types::t] relation) -> bool
61
82
 
62
- def check_method: (untyped name, untyped relation) -> untyped
83
+ def check_interface: (Relation[Interface::Shape] relation) -> Result::t
63
84
 
64
- def check_type_application: (untyped result, untyped type_params, untyped type_args) { () -> untyped } -> untyped
85
+ def check_method: (Symbol name, Relation[Interface::Shape::Entry] relation) -> Result::t
65
86
 
66
- def check_generic_method_type: (untyped name, untyped relation) -> untyped
87
+ def check_generic_method_type: (Symbol name, Relation[Interface::MethodType] relation) -> Result::t
67
88
 
68
- def check_constraints: (untyped relation, variables: untyped, variance: untyped) -> untyped
89
+ def check_constraints: (Relation[untyped] relation, variables: Enumerable[Symbol], variance: VariableVariance) -> Result::t
69
90
 
70
- def check_method_type: (untyped name, untyped relation) -> untyped
91
+ def check_method_type: (Symbol name, Relation[Interface::MethodType] relation) -> Result::t
71
92
 
72
- def check_block_given: (untyped name, untyped relation) { () -> untyped } -> untyped
93
+ # Receives subtyping relation of blocks `b <: b'` where `b` and `b'` are expanded from
94
+ # subtyping relation of two method types `(...) _b_ -> T <: (...) _b'_ -> S`.
95
+ #
96
+ # Returns `true` is the relation is satisfied immediately.
97
+ # Returns a Relation when the given relation can be expanded to relation between Interface::Block.
98
+ # Returns a failure otherwise.
99
+ #
100
+ def expand_block_given: (Symbol name, Relation[Interface::Block?] relation) -> (Relation[Interface::Block] | true | Result::t)
73
101
 
74
- def check_function: (untyped name, untyped relation) -> untyped
102
+ # Receives a subtyping relation between self bindings `S <: S'` that is included in procs or blocks as:
103
+ #
104
+ # * `^() [self: S] -> T <: ^() [self: S'] -> T` (proc)
105
+ # * `() { () [self: S'] -> T } -> T <: () { () [self: S] -> T } -> T` (block in method type)
106
+ #
107
+ def check_self_type_binding: (Relation[untyped], AST::Types::t? sub_self, AST::Types::t? super_self) -> Result::t?
75
108
 
76
- def check_method_params: (untyped name, untyped relation) -> untyped
109
+ def check_function: (Symbol name, Relation[Interface::Function] relation) -> Result::t
77
110
 
78
- # ```rbs
79
- # (Symbol, Relation[MethodType]) -> (Array[[Symbol, Symbol]] | Result::t)
80
- # [A] (Symbol, Relation[MethodType]) { (Array[[Symbol, Symbol]]) -> A } -> (A | Result::t)
81
- # ````
82
- def match_method_type: (untyped name, untyped relation) { (untyped) -> untyped } -> untyped
111
+ def check_method_params: (Symbol name, Relation[Interface::Function::Params] relation) -> Result::t
83
112
 
84
- def match_params: (untyped name, untyped relation) -> untyped
113
+ # Returns `nil` when given two method_types are structually comparable.
114
+ # Returns a failure otherwise.
115
+ #
116
+ def match_method_type_fails?: (Symbol name, Interface::MethodType method_type1, Interface::MethodType method_type2) -> (nil | Result::t)
85
117
 
86
- def expand_alias: (untyped `type`) { () -> untyped } -> untyped
118
+ def match_params: (Symbol name, Relation[Interface::Function::Params] relation) -> (Array[[AST::Types::t, AST::Types::t]] | Result::t)
119
+
120
+ def expand_alias: (AST::Types::t `type`) -> AST::Types::t
87
121
 
88
122
  # Returns the shortest type paths for one of the _unknown_ type variables.
89
123
  # Returns nil if there is no path.
90
- def hole_path: (untyped `type`, ?untyped path) -> untyped
124
+ def hole_path: (AST::Types::t `type`, ?Array[AST::Types::t] path) -> Array[AST::Types::t]?
125
+
126
+ def Relation: [T < Object] (T sub, T sup) -> Relation[T]
91
127
  end
92
128
  end
93
129
  end