@@ -739,6 +739,61 @@ def title; end
739739 assert_success_status ( result )
740740 end
741741
742+ it "uses the last overload when rewriting RBS comments" do
743+ @project . write! ( "lib/post.rb" , <<~RB )
744+ # typed: strict
745+
746+ class Post
747+ #: (String value) -> String
748+ #: (Integer value) -> Integer
749+ def find(value)
750+ value
751+ end
752+ end
753+ RB
754+
755+ @project . write! ( "lib/compilers/rbs_comment_compiler.rb" , <<~RB )
756+ require "post"
757+
758+ class RbsCommentCompiler < Tapioca::Dsl::Compiler
759+ extend T::Sig
760+ extend T::Generic
761+
762+ ConstantType = type_member { { fixed: T.class_of(::Post) } }
763+
764+ sig { override.void }
765+ def decorate
766+ root.create_path(constant) do |klass|
767+ create_method_from_def(klass, constant.instance_method(:find))
768+ end
769+ end
770+
771+ sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
772+ def self.gather_constants
773+ [::Post]
774+ end
775+ end
776+ RB
777+
778+ result = @project . tapioca ( "dsl Post --only RbsCommentCompiler" )
779+
780+ assert_empty_stderr ( result )
781+ assert_project_file_equal ( "sorbet/rbi/dsl/post.rbi" , <<~RBI )
782+ # typed: true
783+
784+ # DO NOT EDIT MANUALLY
785+ # This is an autogenerated file for dynamic methods in `Post`.
786+ # Please instead update this file by running `bin/tapioca dsl Post`.
787+
788+
789+ class Post
790+ sig { params(value: ::Integer).returns(::Integer) }
791+ def find(value); end
792+ end
793+ RBI
794+ assert_success_status ( result )
795+ end
796+
742797 it "raises when the host calls Bootsnap.setup under TAPIOCA_RBS_CACHE=1" do
743798 @project . write! ( "lib/post.rb" , <<~RB )
744799 require "bootsnap"
0 commit comments