Skip to content

Commit 05f1642

Browse files
authored
Merge pull request #804 from Shopify/at-rbs-override-allow-incompatible-visibility
Add support for `override(allow_incompatible: :visibility)`
2 parents 0bef5d6 + d4170fc commit 05f1642

7 files changed

Lines changed: 556 additions & 424 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ GEM
5353
racc (1.8.1)
5454
rainbow (3.1.1)
5555
rake (13.3.0)
56-
rbi (0.3.6)
56+
rbi (0.3.7)
5757
prism (~> 1.0)
5858
rbs (>= 3.4.4)
5959
rbs (4.0.0.dev.4)

lib/spoom/rbs.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def method_annotations
4343
"@final",
4444
"@override",
4545
"@override(allow_incompatible: true)",
46+
"@override(allow_incompatible: :visibility)",
4647
"@overridable",
4748
"@without_runtime"
4849
true

lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ def apply_member_annotations(annotations, sig)
248248
when "@override(allow_incompatible: true)"
249249
sig.is_override = true
250250
sig.allow_incompatible_override = true
251+
when "@override(allow_incompatible: :visibility)"
252+
sig.is_override = true
253+
sig.allow_incompatible_override_visibility = true
251254
when "@overridable"
252255
sig.is_overridable = true
253256
when "@without_runtime"

lib/spoom/sorbet/translate/sorbet_sigs_to_rbs_comments.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ def apply_member_annotations(sigs)
297297
if sigs.any? { |_, sig| sig.is_override }
298298
@rewriter << if sigs.any? { |_, sig| sig.allow_incompatible_override }
299299
Source::Insert.new(insert_pos, "# @override(allow_incompatible: true)\n#{indent}")
300+
elsif sigs.any? { |_, sig| sig.allow_incompatible_override_visibility }
301+
Source::Insert.new(insert_pos, "# @override(allow_incompatible: :visibility)\n#{indent}")
300302
else
301303
Source::Insert.new(insert_pos, "# @override\n#{indent}")
302304
end

0 commit comments

Comments
 (0)