steep 1.10.0 → 2.1.0.dev.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +84 -1
- data/CLAUDE.md +114 -0
- data/README.md +2 -2
- data/Rakefile +365 -150
- data/Steepfile +13 -13
- data/doc/release.md +264 -0
- data/lib/steep/annotation_parser.rb +5 -1
- data/lib/steep/annotations_helper.rb +12 -2
- data/lib/steep/ast/node/type_application.rb +22 -16
- data/lib/steep/ast/node/type_assertion.rb +7 -4
- data/lib/steep/ast/types/factory.rb +3 -2
- data/lib/steep/cli.rb +246 -2
- data/lib/steep/daemon/configuration.rb +19 -0
- data/lib/steep/daemon/server.rb +476 -0
- data/lib/steep/daemon.rb +201 -0
- data/lib/steep/diagnostic/ruby.rb +54 -12
- data/lib/steep/diagnostic/signature.rb +31 -8
- data/lib/steep/drivers/check.rb +301 -140
- data/lib/steep/drivers/print_project.rb +9 -10
- data/lib/steep/drivers/query.rb +102 -0
- data/lib/steep/drivers/start_server.rb +19 -0
- data/lib/steep/drivers/stop_server.rb +20 -0
- data/lib/steep/drivers/watch.rb +2 -2
- data/lib/steep/index/rbs_index.rb +38 -13
- data/lib/steep/index/signature_symbol_provider.rb +24 -3
- data/lib/steep/interface/builder.rb +48 -15
- data/lib/steep/interface/shape.rb +13 -5
- data/lib/steep/locator.rb +377 -0
- data/lib/steep/node_helper.rb +2 -2
- data/lib/steep/project/dsl.rb +26 -5
- data/lib/steep/project/group.rb +8 -2
- data/lib/steep/project/target.rb +16 -2
- data/lib/steep/project.rb +21 -2
- data/lib/steep/server/base_worker.rb +2 -2
- data/lib/steep/server/change_buffer.rb +2 -1
- data/lib/steep/server/custom_methods.rb +12 -0
- data/lib/steep/server/inline_source_change_detector.rb +94 -0
- data/lib/steep/server/interaction_worker.rb +51 -74
- data/lib/steep/server/lsp_formatter.rb +48 -12
- data/lib/steep/server/master.rb +100 -18
- data/lib/steep/server/target_group_files.rb +124 -151
- data/lib/steep/server/type_check_controller.rb +276 -123
- data/lib/steep/server/type_check_worker.rb +104 -3
- data/lib/steep/services/completion_provider/rbs.rb +74 -0
- data/lib/steep/services/completion_provider/ruby.rb +652 -0
- data/lib/steep/services/completion_provider/type_name.rb +243 -0
- data/lib/steep/services/completion_provider.rb +39 -662
- data/lib/steep/services/content_change.rb +14 -1
- data/lib/steep/services/file_loader.rb +4 -2
- data/lib/steep/services/goto_service.rb +271 -68
- data/lib/steep/services/hover_provider/content.rb +67 -0
- data/lib/steep/services/hover_provider/rbs.rb +8 -9
- data/lib/steep/services/hover_provider/ruby.rb +124 -65
- data/lib/steep/services/hover_provider/singleton_methods.rb +4 -0
- data/lib/steep/services/signature_help_provider.rb +1 -1
- data/lib/steep/services/signature_service.rb +129 -54
- data/lib/steep/services/type_check_service.rb +72 -27
- data/lib/steep/signature/validator.rb +30 -18
- data/lib/steep/source/ignore_ranges.rb +14 -4
- data/lib/steep/source.rb +21 -7
- data/lib/steep/tagged_logging.rb +39 -0
- data/lib/steep/type_construction.rb +111 -24
- data/lib/steep/type_inference/block_params.rb +7 -7
- data/lib/steep/type_inference/context.rb +4 -2
- data/lib/steep/type_inference/logic_type_interpreter.rb +24 -3
- data/lib/steep/type_inference/method_call.rb +4 -0
- data/lib/steep/type_inference/type_env.rb +1 -1
- data/lib/steep/typing.rb +3 -5
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +42 -32
- data/manual/ruby-diagnostics.md +67 -0
- data/sample/Steepfile +1 -0
- data/sample/lib/conference.rb +1 -0
- data/sample/lib/deprecated.rb +6 -0
- data/sample/lib/inline.rb +43 -0
- data/sample/sig/generics.rbs +3 -0
- data/steep.gemspec +4 -5
- metadata +27 -26
- data/lib/steep/services/type_name_completion.rb +0 -236
data/doc/release.md
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Releasing Steep
|
|
2
|
+
|
|
3
|
+
A release is a pull request and one workflow run. Everything that leaves the
|
|
4
|
+
repository — the tag, the gem, and the GitHub release — is produced by the
|
|
5
|
+
`Release gem` workflow, so nothing has to be built or pushed from a laptop.
|
|
6
|
+
|
|
7
|
+
There are three kinds of release, and they differ in what gets written up:
|
|
8
|
+
|
|
9
|
+
| Version | CHANGELOG section | GitHub release |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `X.Y.Z` | The whole cycle since the previous release proper, prereleases included | Published |
|
|
12
|
+
| `X.Y.Z.pre.N` | What changed since `X.Y.Z.pre.N-1` | Published, marked as a prerelease |
|
|
13
|
+
| `X.Y.Z.dev.N` | None | None |
|
|
14
|
+
|
|
15
|
+
`.dev.N` releases are cut from the development line for people who need a change
|
|
16
|
+
early, so they are gems and tags and nothing else.
|
|
17
|
+
|
|
18
|
+
## Prerequisites
|
|
19
|
+
|
|
20
|
+
Push rights to the `steep` gem on RubyGems are **not** needed: the workflow
|
|
21
|
+
authenticates through a trusted publisher registered for this repository and
|
|
22
|
+
`release.yml`. What is needed is write access to the repository, since that is
|
|
23
|
+
what lets you dispatch the workflow.
|
|
24
|
+
|
|
25
|
+
## Steps
|
|
26
|
+
|
|
27
|
+
The release pull request in step 1 is merged by a person who has reviewed it. Its merge commit is
|
|
28
|
+
what step 2 dispatches, tags, and pushes to RubyGems, and none of that can be taken back — so
|
|
29
|
+
prepare that pull request and stop there, rather than merging it and carrying on to step 2.
|
|
30
|
+
|
|
31
|
+
The bump that starts a new minor is the only other pull request that sets `Steep::VERSION`. It
|
|
32
|
+
publishes nothing and another bump undoes it, so one opened on an explicit request can go through
|
|
33
|
+
on its own.
|
|
34
|
+
|
|
35
|
+
### 1. Prepare the release
|
|
36
|
+
|
|
37
|
+
Open a pull request that carries everything the release needs:
|
|
38
|
+
|
|
39
|
+
- `lib/steep/version.rb` — set `Steep::VERSION` to the version being released.
|
|
40
|
+
- `CHANGELOG.md` — add a section for the new version, directly under the `# CHANGELOG` heading.
|
|
41
|
+
Sections are newest first.
|
|
42
|
+
|
|
43
|
+
Label the pull request `skip-changelog`. It carries no change of its own, and without the label it
|
|
44
|
+
shows up in the next release's list.
|
|
45
|
+
|
|
46
|
+
`rake gem:changelog` lists the pull requests merged since the last release, already formatted:
|
|
47
|
+
|
|
48
|
+
```console
|
|
49
|
+
$ bundle exec rake gem:changelog | pbcopy
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Where it starts follows `Steep::VERSION`, so bump the version first: a prerelease starts from the
|
|
53
|
+
latest tag, and a release proper skips the prerelease tags and starts from the previous release
|
|
54
|
+
proper. Pass a version to override it (`rake 'gem:changelog[2.0.0]'`). Only the list goes to
|
|
55
|
+
STDOUT, so it pipes cleanly. Pull requests labeled `skip-changelog` are left out and reported on
|
|
56
|
+
STDERR.
|
|
57
|
+
|
|
58
|
+
Sort the list into the sections below. `rake gem:changelog:json` prints the same pull requests with
|
|
59
|
+
the changed files, labels, and body of each, which is what the sorting is based on.
|
|
60
|
+
|
|
61
|
+
Both tasks reach GitHub through `gh`, which a Claude Code on the web session cannot do. See
|
|
62
|
+
[Assembling the changelog without `gh`](#assembling-the-changelog-without-gh) for how the same list
|
|
63
|
+
is produced there.
|
|
64
|
+
|
|
65
|
+
```markdown
|
|
66
|
+
## X.Y.Z (YYYY-MM-DD)
|
|
67
|
+
|
|
68
|
+
### Type checker core
|
|
69
|
+
|
|
70
|
+
### Commandline tool
|
|
71
|
+
|
|
72
|
+
### Language server
|
|
73
|
+
|
|
74
|
+
### Miscellaneous
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The sections always appear in this order; delete the ones that end up empty. One thing scales with
|
|
78
|
+
the size of the release: **summary paragraphs**, above the first section. A patch release usually
|
|
79
|
+
has none, while 2.0.0 opens with a `### Summary` describing its three major features.
|
|
80
|
+
|
|
81
|
+
The date is the day the gem is released, matching the `vX.Y.Z` tag — not the day this pull request
|
|
82
|
+
is opened. Fix it up before step 2 if the pull request sat for a few days.
|
|
83
|
+
|
|
84
|
+
### 2. Run the `Release gem` workflow
|
|
85
|
+
|
|
86
|
+
Once the pull request is merged, dispatch
|
|
87
|
+
[`release.yml`](../.github/workflows/release.yml) from the Actions tab with two inputs:
|
|
88
|
+
|
|
89
|
+
| Input | Value |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| `commit` | The full 40-character SHA of the merge commit, taken from the merged pull request |
|
|
92
|
+
| `version` | `X.Y.Z`, without the leading `v` |
|
|
93
|
+
|
|
94
|
+
The ref selector picks which copy of the workflow file runs, not what gets released — leave it on
|
|
95
|
+
`master`. Everything is built from `commit`, so the run is unaffected by whatever lands on `master`
|
|
96
|
+
in the meantime, and a patch release cut from a release branch is dispatched the same way as any
|
|
97
|
+
other: the workflow does not care which branch the commit is on.
|
|
98
|
+
|
|
99
|
+
The two inputs say the same thing twice, once as a commit and once as a name, and the run stops
|
|
100
|
+
before anything is built unless they agree with each other and with the repository:
|
|
101
|
+
|
|
102
|
+
- `commit` has to be a full SHA that some branch contains,
|
|
103
|
+
- `version` has to be the `Steep::VERSION` that commit declares,
|
|
104
|
+
- CHANGELOG.md has to start with a section for `version` (skipped for `.dev.N`, which is not
|
|
105
|
+
written up),
|
|
106
|
+
- `vX.Y.Z` must not exist yet.
|
|
107
|
+
|
|
108
|
+
It then:
|
|
109
|
+
|
|
110
|
+
- builds `steep-X.Y.Z.gem`,
|
|
111
|
+
- checks its metadata: the platform, no C extension, `exe/steep` and `lib/steep.rb` present, and
|
|
112
|
+
none of the development directories shipped,
|
|
113
|
+
- installs the gem the way a user would and type checks a small project with it — one that has to
|
|
114
|
+
pass and one that has to fail — so the executable, the dependencies, and the type checker are
|
|
115
|
+
exercised before anything is published,
|
|
116
|
+
- uploads the gem as an artifact,
|
|
117
|
+
- tags `commit` as `vX.Y.Z` and pushes the tag,
|
|
118
|
+
- pushes the gem to RubyGems through trusted publishing,
|
|
119
|
+
- publishes the GitHub release with the notes from CHANGELOG.md, skipping this last step for
|
|
120
|
+
`.dev.N` versions.
|
|
121
|
+
|
|
122
|
+
The tag is created once the gem is known to build and run, and before anything is published: a
|
|
123
|
+
tag can be deleted, while a version pushed to RubyGems can only be yanked.
|
|
124
|
+
|
|
125
|
+
Checking the `dry_run` box runs everything up to the artifact and stops — no tag, no gem pushed,
|
|
126
|
+
no release — which is how the build is exercised without releasing. `version` still has to match
|
|
127
|
+
the commit, so a dry run is also how a release is rehearsed before it is cut.
|
|
128
|
+
|
|
129
|
+
## The version on `master`
|
|
130
|
+
|
|
131
|
+
`Steep::VERSION` on `master` is read one of two ways, told apart by how the version ends:
|
|
132
|
+
|
|
133
|
+
| On `master` | Means |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| `X.Y.0.dev` — a bare `.dev` | `X.Y.0` is being developed |
|
|
136
|
+
| A complete version — `X.Y.Z`, `X.Y.Z.pre.N`, `X.Y.Z.dev.N` | The version *after* the one named is being developed |
|
|
137
|
+
|
|
138
|
+
So `2.0.0` on `master` is not a claim that `master` is 2.0.0. It says 2.0.0 has shipped and what
|
|
139
|
+
comes after it is being worked on. Both become true the moment the release is tagged, so **nothing
|
|
140
|
+
has to be done to `master` after a release**.
|
|
141
|
+
|
|
142
|
+
The bare `X.Y.0.dev` is the exception because it is the one version that names a target rather than
|
|
143
|
+
a predecessor: a new minor is developed towards `X.Y.0` for a long time, before it is known whether
|
|
144
|
+
the next thing to ship is `X.Y.0.pre.1` or `X.Y.0` itself. Setting it is the only version change
|
|
145
|
+
that has to be made deliberately.
|
|
146
|
+
|
|
147
|
+
`rake gem:changelog` reads `Steep::VERSION` too, to decide where the next changelog starts — but
|
|
148
|
+
the version is set to the one being released before the changelog is generated, so it sees that
|
|
149
|
+
rather than whatever `master` was carrying.
|
|
150
|
+
|
|
151
|
+
## Starting a new minor
|
|
152
|
+
|
|
153
|
+
`master` is the development line of one minor at a time. Moving it from `X.Y` to `X.(Y+1)` is not
|
|
154
|
+
part of any one release — it is the decision that the `X.Y` line is done, taken whenever that
|
|
155
|
+
becomes true — and it is the one moment the version on `master` is changed by hand. Two changes, in
|
|
156
|
+
opposite places:
|
|
157
|
+
|
|
158
|
+
1. **Branch the line being left behind**, from the last `master` commit that belongs to it:
|
|
159
|
+
|
|
160
|
+
```console
|
|
161
|
+
$ git switch --create aaa-X.Y.x <that commit>
|
|
162
|
+
$ git push -u origin aaa-X.Y.x
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Branch from the commit *before* the bump below, so the branch keeps the version its line was
|
|
166
|
+
released under. Patch releases of `X.Y` are cut from here from now on, with their changes
|
|
167
|
+
cherry-picked from `master` — see [Backports](#backports). The `aaa-` prefix carries no meaning
|
|
168
|
+
beyond sorting the release branches to the top of the branch list.
|
|
169
|
+
|
|
170
|
+
2. **Bump `master`** to `X.(Y+1).0.dev`, in a pull request labeled `skip-changelog` like the
|
|
171
|
+
release pull request itself.
|
|
172
|
+
|
|
173
|
+
One loose end that is easy to forget: **the release note of the new line**. `rake gem:gh_release`
|
|
174
|
+
links every published release to `https://github.com/soutaro/steep/wiki/Release-Note-X.Y`, built
|
|
175
|
+
from the version number without checking that the page is there. Nothing has to be written when
|
|
176
|
+
the line starts — the page comes together as the first release proper of the line comes into view
|
|
177
|
+
— but it does have to exist by the time that release is published, or its notes link to an empty
|
|
178
|
+
page.
|
|
179
|
+
|
|
180
|
+
## Backports
|
|
181
|
+
|
|
182
|
+
A patch release is cut from a release branch (`aaa-X.Y.x`), and what it carries beyond the previous
|
|
183
|
+
release is cherry-picked from the development line. Cherry-pick with `-x`:
|
|
184
|
+
|
|
185
|
+
```console
|
|
186
|
+
$ git cherry-pick -x <commit>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
`-x` records the commit the change was copied from, and that recorded line is what `rake
|
|
190
|
+
gem:changelog` follows to reach the pull request the change was written and reviewed in. Without
|
|
191
|
+
it, the only pull request a backported commit is associated with is the one that carried the
|
|
192
|
+
backport, which says nothing about the change and is the same for every commit it brought over.
|
|
193
|
+
|
|
194
|
+
## Assembling the changelog without `gh`
|
|
195
|
+
|
|
196
|
+
A release can be prepared from a Claude Code on the web session, with one exception:
|
|
197
|
+
`gem:changelog` and `gem:changelog:json` cannot run there. Both go through `gh`, and in such a
|
|
198
|
+
session `api.github.com` is blocked at the agent proxy for anything the shell does. `gh` is not
|
|
199
|
+
installed, installing it does not help, and rewriting the tasks against REST or Net::HTTP would be
|
|
200
|
+
blocked the same way — the refusal is keyed on the session rather than on the client.
|
|
201
|
+
|
|
202
|
+
Nothing else in the release is affected. `gem:check_release` and `gem:tag` read git and the working
|
|
203
|
+
tree, and `gem:gh_release` runs on a runner, where `gh` and `github.token` both work.
|
|
204
|
+
|
|
205
|
+
What the session does have is the GitHub MCP server, which reaches the API through its own
|
|
206
|
+
credentials. The changelog is assembled with its tools, in the three steps the rake task takes.
|
|
207
|
+
|
|
208
|
+
**1. Where the changelog starts.** The rule is `changelog_base`: a prerelease starts from the
|
|
209
|
+
latest tag, a release proper skips the prerelease tags. Tags are not fetched by default.
|
|
210
|
+
|
|
211
|
+
```console
|
|
212
|
+
$ git fetch origin --tags
|
|
213
|
+
$ git describe --tags --match 'v*' --abbrev=0 --exclude 'v*.pre*' --exclude 'v*.dev*'
|
|
214
|
+
v2.0.0
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Drop the two `--exclude` flags for a prerelease, which starts at the latest tag whatever it is.
|
|
218
|
+
|
|
219
|
+
**2. The commits.**
|
|
220
|
+
|
|
221
|
+
```console
|
|
222
|
+
$ git log --format=%H v2.0.0..HEAD
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**3. The pull requests they came from.** List the merged pull requests with `list_pull_requests`
|
|
226
|
+
(`base: master`, `state: closed`, `sort: updated`, `direction: desc`, and `fields: number, title,
|
|
227
|
+
labels, merged_at, head`), paging back until `merged_at` predates the base tag, and keep the ones
|
|
228
|
+
whose `head.sha` appears in the commit list from step 2. That intersection is what the task's
|
|
229
|
+
GraphQL `associatedPullRequests` query answers, reached from the other side.
|
|
230
|
+
|
|
231
|
+
Then drop the pull requests labeled `skip-changelog` and format the rest newest first, which is the
|
|
232
|
+
order of step 2:
|
|
233
|
+
|
|
234
|
+
```markdown
|
|
235
|
+
* {title} ([#{number}](https://github.com/soutaro/steep/pull/{number}))
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Sorting them into sections needs the changed files, which `gem:changelog:json` would have supplied:
|
|
239
|
+
`pull_request_read` with `get_files` per pull request, or `get` for the body.
|
|
240
|
+
|
|
241
|
+
Four things about that matching, the first of which is a trap:
|
|
242
|
+
|
|
243
|
+
- **Do not read the numbers from `Merge pull request #N` commit subjects.** A squashed or rebased
|
|
244
|
+
pull request never writes that subject at all. Matching `head.sha` does not have that failure
|
|
245
|
+
mode.
|
|
246
|
+
- `head.sha` is in the history because this repository merges pull requests with merge commits. A
|
|
247
|
+
squashed or rebased one would need its `merge_commit_sha`, which the listing does not carry.
|
|
248
|
+
- The listing reports `merged: false` for pull requests that are merged — the field is not
|
|
249
|
+
populated by that endpoint. Read `merged_at` instead.
|
|
250
|
+
- On a release branch the commits are cherry-picks, so resolve the `(cherry picked from commit
|
|
251
|
+
<sha>)` trailer first and match the recorded origin, as `changelog_origins` does. Matching the
|
|
252
|
+
cherry-pick itself attributes every backport to the pull request that carried it.
|
|
253
|
+
|
|
254
|
+
## Notes
|
|
255
|
+
|
|
256
|
+
- Prereleases (`X.Y.Z.pre.N`) are only installed with `gem install steep --pre`; a plain
|
|
257
|
+
`gem install steep` is unaffected.
|
|
258
|
+
- `rake 'gem:check_release[X.Y.Z]'` and `rake gem:tag` are what the workflow runs to check the
|
|
259
|
+
release and to create the tag. Both work locally, which is the fallback if the tag ever has to
|
|
260
|
+
be created by hand.
|
|
261
|
+
- Those two tasks and `rake gem:gh_release` come from the Rakefile of the commit being released,
|
|
262
|
+
not from the branch the workflow was dispatched from. Releasing from a release branch
|
|
263
|
+
(`aaa-X.Y.x`) therefore needs the release tooling on that branch as well; without it the run
|
|
264
|
+
fails on the missing task, before publishing anything.
|
|
@@ -56,8 +56,12 @@ module Steep
|
|
|
56
56
|
RBS::Parser.parse_type(string)
|
|
57
57
|
rescue RBS::ParsingError => exn
|
|
58
58
|
raise SyntaxError.new(source: string, location: loc, exn: exn)
|
|
59
|
-
end
|
|
59
|
+
end
|
|
60
60
|
|
|
61
|
+
unless type
|
|
62
|
+
raise SyntaxError.new(source: string, location: loc, message: "Failed to parse a type in annotation")
|
|
63
|
+
end
|
|
64
|
+
|
|
61
65
|
unless (type.location || raise).source == string.strip
|
|
62
66
|
raise SyntaxError.new(source: string, location: loc, message: "Failed to parse a type in annotation")
|
|
63
67
|
end
|
|
@@ -21,9 +21,19 @@ module Steep
|
|
|
21
21
|
when type_name.class?
|
|
22
22
|
case
|
|
23
23
|
when decl = env.class_decls.fetch(type_name, nil)
|
|
24
|
-
decl.
|
|
24
|
+
decl.each_decl.flat_map do |decl|
|
|
25
|
+
if decl.is_a?(RBS::AST::Declarations::Base)
|
|
26
|
+
decl.annotations
|
|
27
|
+
else
|
|
28
|
+
[]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
25
31
|
when decl = env.class_alias_decls.fetch(type_name, nil)
|
|
26
|
-
decl.decl.
|
|
32
|
+
if decl.decl.is_a?(RBS::AST::Declarations::Base)
|
|
33
|
+
decl.decl.annotations
|
|
34
|
+
else
|
|
35
|
+
[] #: Array[RBS::AST::Annotation]
|
|
36
|
+
end
|
|
27
37
|
end
|
|
28
38
|
when type_name.interface?
|
|
29
39
|
if decl = env.interface_decls.fetch(type_name, nil)
|
|
@@ -25,33 +25,21 @@ module Steep
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def types(context, subtyping, type_vars)
|
|
28
|
-
resolver = RBS::Resolver::TypeNameResolver.new(subtyping.factory.env)
|
|
29
|
-
|
|
30
28
|
# @type var types: Array[LocatedValue[Types::t]]
|
|
31
29
|
types = []
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
while true
|
|
36
|
-
rbs_ty = RBS::Parser.parse_type(loc.buffer, range: loc.range, variables: type_vars) or break
|
|
37
|
-
rbs_loc = rbs_ty.location or raise
|
|
38
|
-
ty = rbs_ty.map_type_name {|name| resolver.resolve(name, context: context) || name.absolute! }
|
|
39
|
-
|
|
31
|
+
each_rbs_type(context, subtyping, type_vars) do |rbs_ty|
|
|
40
32
|
validator = Signature::Validator.new(checker: subtyping)
|
|
41
33
|
validator.rescue_validation_errors do
|
|
42
|
-
validator.validate_type(
|
|
34
|
+
validator.validate_type(rbs_ty)
|
|
43
35
|
end
|
|
44
36
|
|
|
45
37
|
if validator.has_error?
|
|
46
38
|
return validator.each_error
|
|
47
39
|
end
|
|
48
40
|
|
|
49
|
-
ty = subtyping.factory.type(
|
|
50
|
-
types << LocatedValue.new(value: ty, location:
|
|
51
|
-
|
|
52
|
-
match = RBS::Location.new(loc.buffer, rbs_loc.end_pos, type_location.end_pos).source.match(/\A\s*,\s*/) or break
|
|
53
|
-
offset = match.length
|
|
54
|
-
loc = RBS::Location.new(loc.buffer, rbs_loc.end_pos + offset, type_location.end_pos)
|
|
41
|
+
ty = subtyping.factory.type(rbs_ty)
|
|
42
|
+
types << LocatedValue.new(value: ty, location: rbs_ty.location || raise)
|
|
55
43
|
end
|
|
56
44
|
|
|
57
45
|
types
|
|
@@ -68,6 +56,24 @@ module Steep
|
|
|
68
56
|
end
|
|
69
57
|
end
|
|
70
58
|
|
|
59
|
+
def each_rbs_type(context, subtyping, type_vars)
|
|
60
|
+
resolver = RBS::Resolver::TypeNameResolver.build(subtyping.factory.env)
|
|
61
|
+
|
|
62
|
+
loc = type_location
|
|
63
|
+
|
|
64
|
+
while true
|
|
65
|
+
type = RBS::Parser.parse_type(loc.buffer, range: loc.range, variables: type_vars) or break
|
|
66
|
+
type_loc = type.location or raise
|
|
67
|
+
type = type.map_type_name {|name| resolver.resolve(name, context: context) || name.absolute! }
|
|
68
|
+
|
|
69
|
+
yield type
|
|
70
|
+
|
|
71
|
+
match = RBS::Location.new(loc.buffer, type_loc.end_pos, type_location.end_pos).source.match(/\A\s*,\s*/) or break
|
|
72
|
+
offset = match.length
|
|
73
|
+
loc = RBS::Location.new(loc.buffer, type_loc.end_pos + offset, type_location.end_pos)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
71
77
|
def type_str
|
|
72
78
|
@type_str ||= source.delete_prefix("$").lstrip
|
|
73
79
|
end
|
|
@@ -16,11 +16,15 @@ module Steep
|
|
|
16
16
|
location.start_line
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def
|
|
19
|
+
def rbs_type(context, subtyping, type_vars)
|
|
20
20
|
if ty = RBS::Parser.parse_type(type_location.buffer, range: type_location.range, variables: type_vars, require_eof: true)
|
|
21
|
-
resolver = RBS::Resolver::TypeNameResolver.
|
|
21
|
+
resolver = RBS::Resolver::TypeNameResolver.build(subtyping.factory.env)
|
|
22
22
|
ty = ty.map_type_name {|name| resolver.resolve(name, context: context) || name.absolute! }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
23
25
|
|
|
26
|
+
def type(context, subtyping, type_vars)
|
|
27
|
+
if ty = rbs_type(context, subtyping, type_vars)
|
|
24
28
|
validator = Signature::Validator.new(checker: subtyping)
|
|
25
29
|
validator.rescue_validation_errors do
|
|
26
30
|
validator.validate_type(ty)
|
|
@@ -40,9 +44,8 @@ module Steep
|
|
|
40
44
|
|
|
41
45
|
def type_syntax?
|
|
42
46
|
RBS::Parser.parse_type(type_location.buffer, range: type_location.range, variables: [], require_eof: true)
|
|
43
|
-
true
|
|
44
47
|
rescue ::RBS::ParsingError
|
|
45
|
-
|
|
48
|
+
nil
|
|
46
49
|
end
|
|
47
50
|
|
|
48
51
|
def type?(context, subtyping, type_vars)
|
|
@@ -21,7 +21,7 @@ module Steep
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def type_name_resolver
|
|
24
|
-
@type_name_resolver ||= RBS::Resolver::TypeNameResolver.
|
|
24
|
+
@type_name_resolver ||= RBS::Resolver::TypeNameResolver.build(definition_builder.env)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def type_opt(type)
|
|
@@ -39,7 +39,7 @@ module Steep
|
|
|
39
39
|
def normalize_args(type_name, args)
|
|
40
40
|
case
|
|
41
41
|
when type_name.class?
|
|
42
|
-
if entry = env.
|
|
42
|
+
if entry = env.module_class_entry(type_name, normalized: true)
|
|
43
43
|
type_params = entry.type_params
|
|
44
44
|
end
|
|
45
45
|
when type_name.interface?
|
|
@@ -294,6 +294,7 @@ module Steep
|
|
|
294
294
|
raise "`#{u_}` cannot be type parameter upper bound"
|
|
295
295
|
end
|
|
296
296
|
},
|
|
297
|
+
lower_bound: nil,
|
|
297
298
|
location: type_param.location
|
|
298
299
|
).unchecked!(type_param.unchecked)
|
|
299
300
|
end
|