@@ -3254,6 +3254,88 @@ def hello(x) = 123
32543254 end
32553255 end
32563256
3257+ def test_inline_decl__class_with_super
3258+ SignatureManager . new do |manager |
3259+ manager . add_ruby_file ( Pathname ( "a.rb" ) , <<~RUBY )
3260+ class Parent
3261+ # @rbs () -> String
3262+ def parent_method = ""
3263+ end
3264+
3265+ class Child < Parent
3266+ def child_method
3267+ "child"
3268+ end
3269+ end
3270+ RUBY
3271+
3272+ manager . build do |env |
3273+ builder = DefinitionBuilder . new ( env : env )
3274+
3275+ builder . build_instance ( type_name ( "::Child" ) ) . tap do |definition |
3276+ # Should have methods from both Child and Parent
3277+ assert_equal Set [ :child_method , :parent_method ] , Set . new ( definition . methods . keys ) & Set [ :child_method , :parent_method ]
3278+
3279+ definition . methods [ :parent_method ] . tap do |method |
3280+ assert_equal type_name ( "::Parent" ) , method . defined_in
3281+ assert_equal type_name ( "::Parent" ) , method . implemented_in
3282+ assert_equal [ parse_method_type ( "() -> ::String" ) ] , method . method_types
3283+ end
3284+
3285+ definition . methods [ :child_method ] . tap do |method |
3286+ assert_equal type_name ( "::Child" ) , method . defined_in
3287+ assert_equal type_name ( "::Child" ) , method . implemented_in
3288+ assert_equal [ parse_method_type ( "(?) -> untyped" ) ] , method . method_types
3289+ end
3290+ end
3291+
3292+ # Check ancestors
3293+ ancestors = builder . ancestor_builder . instance_ancestors ( type_name ( "::Child" ) )
3294+ assert_equal type_name ( "::Parent" ) , ancestors . ancestors [ 1 ] . name
3295+ end
3296+ end
3297+ end
3298+
3299+ def test_inline_decl__class_with_super_type_args
3300+ SignatureManager . new do |manager |
3301+ manager . files [ Pathname ( "generics.rbs" ) ] = <<~RBS
3302+ class MyArray[T]
3303+ def first: () -> T
3304+ end
3305+ RBS
3306+
3307+ manager . add_ruby_file ( "string_array.rb" , <<~RUBY )
3308+ class StringArray < MyArray #[String]
3309+ def last
3310+ "last"
3311+ end
3312+ end
3313+ RUBY
3314+
3315+ manager . build do |env |
3316+ builder = DefinitionBuilder . new ( env : env )
3317+
3318+ builder . build_instance ( type_name ( "::StringArray" ) ) . tap do |definition |
3319+ # Should have methods from both StringArray and MyArray
3320+ assert_equal Set [ :last , :first ] , Set . new ( definition . methods . keys ) & Set [ :last , :first ]
3321+
3322+ definition . methods [ :first ] . tap do |method |
3323+ assert_equal type_name ( "::MyArray" ) , method . defined_in
3324+ assert_equal type_name ( "::MyArray" ) , method . implemented_in
3325+ # Type should be substituted with String
3326+ assert_equal [ parse_method_type ( "() -> ::String" ) ] , method . method_types
3327+ end
3328+
3329+ definition . methods [ :last ] . tap do |method |
3330+ assert_equal type_name ( "::StringArray" ) , method . defined_in
3331+ assert_equal type_name ( "::StringArray" ) , method . implemented_in
3332+ assert_equal [ parse_method_type ( "(?) -> untyped" ) ] , method . method_types
3333+ end
3334+ end
3335+ end
3336+ end
3337+ end
3338+
32573339 def test_ruby_mixin_members
32583340 SignatureManager . new do |manager |
32593341 manager . files [ Pathname ( "modules.rbs" ) ] = <<EOF
0 commit comments