Skip to content

Commit b06b1b6

Browse files
committed
Add RBS support for allow_incompatible_override_visibility modifier
Signed-off-by: Alexandre Terrasa <[email protected]>
1 parent 32ab743 commit b06b1b6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/rbi/rbs_printer.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ def visit_method(node)
337337
if node.sigs.any?(&:is_override)
338338
if node.sigs.any?(&:allow_incompatible_override)
339339
printl("# @override(allow_incompatible: true)")
340+
elsif node.sigs.any?(&:allow_incompatible_override_visibility)
341+
printl("# @override(allow_incompatible: :visibility)")
340342
else
341343
printl("# @override")
342344
end

test/rbi/rbs_printer_test.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,11 @@ def foo; end
397397
sig { override(allow_incompatible: true).returns(T.nilable(String)) }
398398
def bar; end
399399
400-
T::Sig::WithoutRuntime.sig { abstract.returns(String) }
400+
sig { override(allow_incompatible: :visibility).returns(T.nilable(String)) }
401401
def baz; end
402+
403+
T::Sig::WithoutRuntime.sig { abstract.returns(String) }
404+
def qux; end
402405
RBI
403406

404407
# Modifiers are ignored in RBS, but we generate comments for them
@@ -413,9 +416,12 @@ def foo: -> void
413416
# @override(allow_incompatible: true)
414417
def bar: -> String?
415418
419+
# @override(allow_incompatible: :visibility)
420+
def baz: -> String?
421+
416422
# @without_runtime
417423
# @abstract
418-
def baz: -> String
424+
def qux: -> String
419425
RBI
420426
end
421427

0 commit comments

Comments
 (0)