diff --git a/lib/rbi/printer.rb b/lib/rbi/printer.rb index 6c594fa0..21e505cc 100644 --- a/lib/rbi/printer.rb +++ b/lib/rbi/printer.rb @@ -666,7 +666,9 @@ def print_sig_as_line(node) def print_sig_as_block(node) modifiers = sig_modifiers(node) - printl("sig do") + printt("sig") + print("(:final)") if node.is_final + printn(" do") indent if modifiers.any? printl(T.must(modifiers.first)) diff --git a/test/rbi/printer_test.rb b/test/rbi/printer_test.rb index a81f318c..1ed94ccf 100644 --- a/test/rbi/printer_test.rb +++ b/test/rbi/printer_test.rb @@ -1138,5 +1138,19 @@ def test_print_sigs_locations def m1; end RBI end + + def test_print_sigs_with_final + sig = Sig.new(is_final: true, return_type: "Integer") + + assert_equal(<<~RBI, sig.string) + sig(:final) { returns(Integer) } + RBI + + assert_equal(<<~RBI, sig.string(max_line_length: 10)) + sig(:final) do + returns(Integer) + end + RBI + end end end