steep 0.46.0 → 0.48.0

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +0 -1
  3. data/CHANGELOG.md +23 -0
  4. data/Gemfile +1 -2
  5. data/Gemfile.lock +18 -22
  6. data/README.md +2 -1
  7. data/lib/steep/annotation_parser.rb +1 -1
  8. data/lib/steep/ast/types/factory.rb +161 -137
  9. data/lib/steep/ast/types/var.rb +14 -3
  10. data/lib/steep/diagnostic/ruby.rb +23 -11
  11. data/lib/steep/diagnostic/signature.rb +60 -15
  12. data/lib/steep/interface/method_type.rb +14 -26
  13. data/lib/steep/interface/type_param.rb +103 -0
  14. data/lib/steep/project/dsl.rb +32 -5
  15. data/lib/steep/project/options.rb +1 -0
  16. data/lib/steep/project/target.rb +1 -0
  17. data/lib/steep/server/base_worker.rb +1 -0
  18. data/lib/steep/server/interaction_worker.rb +9 -9
  19. data/lib/steep/server/type_check_worker.rb +2 -2
  20. data/lib/steep/services/hover_content.rb +3 -0
  21. data/lib/steep/services/signature_service.rb +2 -2
  22. data/lib/steep/services/type_check_service.rb +2 -1
  23. data/lib/steep/signature/validator.rb +221 -49
  24. data/lib/steep/source.rb +5 -1
  25. data/lib/steep/subtyping/cache.rb +30 -0
  26. data/lib/steep/subtyping/check.rb +582 -708
  27. data/lib/steep/subtyping/constraints.rb +66 -30
  28. data/lib/steep/subtyping/relation.rb +60 -0
  29. data/lib/steep/subtyping/result.rb +190 -16
  30. data/lib/steep/type_construction.rb +493 -372
  31. data/lib/steep/type_inference/block_params.rb +1 -1
  32. data/lib/steep/type_inference/context.rb +37 -3
  33. data/lib/steep/type_inference/send_args.rb +1 -12
  34. data/lib/steep/version.rb +1 -1
  35. data/lib/steep.rb +5 -5
  36. data/sample/lib/length.rb +35 -0
  37. data/sample/sig/length.rbs +34 -0
  38. data/smoke/diagnostics/test_expectations.yml +4 -4
  39. data/smoke/diagnostics-rbs/nonregular-type-alias.rbs +3 -0
  40. data/smoke/diagnostics-rbs/recursive-type-alias.rbs +3 -0
  41. data/smoke/diagnostics-rbs/test_expectations.yml +57 -12
  42. data/smoke/extension/e.rbs +1 -1
  43. data/steep.gemspec +1 -1
  44. metadata +11 -10
  45. data/lib/steep/drivers/trace_printer.rb +0 -29
  46. data/lib/steep/interface/method.rb +0 -78
  47. data/lib/steep/subtyping/trace.rb +0 -71
  48. data/sig/project.rbi +0 -109
  49. data/sig/steep/type_inference/send_args.rbs +0 -42
data/sig/project.rbi DELETED
@@ -1,109 +0,0 @@
1
- class Pathname
2
- end
3
-
4
- class Time
5
- def self.now: -> instance
6
- def < : (Time) -> bool
7
- def >=: (Time) -> bool
8
- end
9
-
10
- type annotation = any
11
-
12
- class Steep::Source
13
- def self.parse: (String, path: String, labeling: any) -> instance
14
- def annotations: (block: any, builder: any, current_module: any) -> Array<annotation>
15
- def node: -> any
16
- def find_node: (line: Integer, column: Integer) -> any
17
- end
18
-
19
- class Steep::Typing
20
- attr_reader errors: Array<type_error>
21
- attr_reader nodes: any
22
- end
23
-
24
- type type_error = any
25
-
26
- class Steep::Project::Options
27
- attr_accessor fallback_any_is_error: bool
28
- attr_accessor allow_missing_definitions: bool
29
- end
30
-
31
- class Parser::SyntaxError
32
- end
33
-
34
- class Steep::Project::SourceFile
35
- attr_reader options: Options
36
- attr_reader path: Pathname
37
- attr_accessor content: String
38
- attr_reader content_updated_at: Time
39
-
40
- attr_reader source: (Source | Parser::SyntaxError | nil)
41
- attr_reader typing: Typing?
42
- attr_reader last_type_checked_at: Time?
43
-
44
- def initialize: (path: Pathname, options: Options) -> any
45
- def requires_type_check?: -> bool
46
- def invalidate: -> void
47
- def parse: -> (Source | Parser::SyntaxError)
48
- def errors: -> Array<type_error>?
49
- def type_check: (any) -> void
50
- end
51
-
52
- class Steep::Project::SignatureFile
53
- attr_reader path: Pathname
54
- attr_accessor content: String
55
- attr_reader content_updated_at: Time
56
-
57
- def parse: -> Array<any>
58
- end
59
-
60
- interface Steep::Project::_Listener
61
- def parse_signature: <'x> (project: Project, file: SignatureFile) { -> 'x } -> 'x
62
- def parse_source: <'x> (project: Project, file: SourceFile) { -> 'x } -> 'x
63
- def check: <'x> (project: Project) { -> 'x } -> 'x
64
- def load_signature: <'x> (project: Project) { -> 'x } -> 'x
65
- def validate_signature: <'x> (project: Project) { -> 'x } -> 'x
66
- def type_check_source: <'x> (project: Project, file: SourceFile) { -> 'x } -> 'x
67
- def clear_project: <'x> (project: Project) { -> 'x } -> 'x
68
- end
69
-
70
- class Steep::Project::SignatureLoaded
71
- attr_reader check: any
72
- attr_reader loaded_at: Time
73
- attr_reader file_paths: Array<Pathname>
74
-
75
- def initialize: (check: any, loaded_at: Time, file_paths: Array<Pathname>) -> any
76
- end
77
-
78
- class Steep::Project::SignatureHasSyntaxError
79
- attr_reader errors: Hash<Pathname, any>
80
- def initialize: (errors: Hash<Pathname, any>) -> any
81
- end
82
-
83
- class Steep::Project::SignatureHasError
84
- attr_reader errors: Array<any>
85
- def initialize: (errors: Array<any>) -> any
86
- end
87
-
88
- class Steep::Project
89
- attr_reader listener: _Listener
90
- attr_reader source_files: Hash<Pathname, SourceFile>
91
- attr_reader signature_files: Hash<Pathname, SignatureFile>
92
-
93
- attr_reader signature: (SignatureLoaded | SignatureHasError | SignatureHasSyntaxError | nil)
94
-
95
- def initialize: (?_Listener?) -> any
96
- def clear: -> void
97
- def type_check: (?force_signatures: bool, ?force_sources: bool) -> void
98
-
99
- def success?: -> bool
100
- def has_type_error?: -> bool
101
- def errors: -> Array<type_error>
102
- def each_updated_source: (?force: bool) { (SourceFile) -> void } -> void
103
- | (?force: bool) -> Enumerator<SourceFile, void>
104
- def signature_updated?: -> bool
105
- def reload_signature: -> void
106
- def validate_signature: (any) -> Array<any>
107
-
108
- def type_of: (path: Pathname, line: Integer, column: Integer) -> any
109
- end
@@ -1,42 +0,0 @@
1
- module Steep
2
- type node = untyped
3
-
4
- module TypeInference
5
- class SendArgs
6
- class PositionalArgs
7
- end
8
-
9
- class KeywordArgs
10
- type value = ArgTypePairs | UnexpectedKeyword | MissingKeyword
11
-
12
- class ArgTypePairs
13
- end
14
-
15
- class UnexpectedKeyword
16
- end
17
-
18
- class MissingKeyword
19
- end
20
-
21
- def consume: () -> [value, self]?
22
-
23
- def consume_keys: (Array[Symbol], node: node) -> [AST::Types::t | UnexpectedKeyword, self]
24
- end
25
-
26
-
27
- type error = Diagnostics::Ruby::IncompatibleArguments
28
- | Diagnostics::Ruby::UnexpectedBlockGiven
29
- | Diagnostics::Ruby::RequiredBlockMissing
30
-
31
- type arg = PositionalArgs::NodeParamPair
32
- | PositionalArgs::NodeTypePair
33
- | PositionalArgs::SplatArg
34
- | PositionalArgs::UnexpectedArg
35
- | KeywordArgs::ArgTypePairs
36
- | KeywordArgs::SplatArg
37
- | KeywordArgs::UnexpectedKeyword
38
-
39
- def each_arg: (TypeConstruction) { (arg, TypeConstruction) -> TypeConstruction } -> Array[error]
40
- end
41
- end
42
- end