Skip to content

Commit

Permalink
Merge pull request #1415 from ksss/runtime-superclass
Browse files Browse the repository at this point in the history
Super class should be absolute paths.
  • Loading branch information
soutaro authored Aug 11, 2023
2 parents 69311e1 + 1ee3451 commit 0041bc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/rbs/prototype/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def generate_super_class(mod)
RBS.logger.warn("Skipping anonymous superclass #{mod.superclass} of #{mod}")
nil
else
super_name = to_type_name(const_name(mod.superclass), full_name: true)
super_name = to_type_name(const_name(mod.superclass), full_name: true).absolute!
super_args = type_args(super_name)
AST::Declarations::Class::Super.new(name: super_name, args: super_args, location: nil)
end
Expand Down
28 changes: 14 additions & 14 deletions test/rbs/runtime_prototype_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_1

assert_write p.decls, <<-EOF
module RBS
class RuntimePrototypeTest < Test::Unit::TestCase
class RuntimePrototypeTest < ::Test::Unit::TestCase
module TestTargets
module Bar
end
Expand All @@ -58,7 +58,7 @@ module Foo
extend Comparable
end
class Test < String
class Test < ::String
include RBS::RuntimePrototypeTest::TestTargets::Foo
extend RBS::RuntimePrototypeTest::TestTargets::Bar
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_merge_types
SignatureManager.new do |manager|
manager.files[Pathname("foo.rbs")] = <<EOF
class RBS
class RuntimePrototypeTest < Test::Unit::TestCase
class RuntimePrototypeTest < ::Test::Unit::TestCase
class TestTargets
class Test
def self.baz: () -> void
Expand All @@ -111,7 +111,7 @@ def bar: () -> void

assert_write p.decls, <<-EOF
module RBS
class RuntimePrototypeTest < Test::Unit::TestCase
class RuntimePrototypeTest < ::Test::Unit::TestCase
module TestTargets
module Bar
end
Expand All @@ -122,7 +122,7 @@ module Foo
extend Comparable
end
class Test < String
class Test < ::String
include RBS::RuntimePrototypeTest::TestTargets::Foo
extend RBS::RuntimePrototypeTest::TestTargets::Bar
Expand Down Expand Up @@ -172,9 +172,9 @@ def test_include_owner

assert_write p.decls, <<-EOF
module RBS
class RuntimePrototypeTest < Test::Unit::TestCase
class RuntimePrototypeTest < ::Test::Unit::TestCase
module IncludeTests
class ChildClass < RBS::RuntimePrototypeTest::IncludeTests::SuperClass
class ChildClass < ::RBS::RuntimePrototypeTest::IncludeTests::SuperClass
def self.foo: () -> untyped
public
Expand Down Expand Up @@ -250,7 +250,7 @@ def test_argument_forwarding

assert_write p.decls, <<-EOF
module RBS
class RuntimePrototypeTest < Test::Unit::TestCase
class RuntimePrototypeTest < ::Test::Unit::TestCase
class TestForArgumentForwarding
public
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_for_overwritten_module_name

assert_write p.decls, <<~RBS
module RBS
class RuntimePrototypeTest < Test::Unit::TestCase
class RuntimePrototypeTest < ::Test::Unit::TestCase
module TestForOverrideModuleName
class C
include RBS::RuntimePrototypeTest::TestForOverrideModuleName::M
Expand All @@ -303,7 +303,7 @@ def self.to_s: () -> untyped
INSTANCE: C
end
class C2 < RBS::RuntimePrototypeTest::TestForOverrideModuleName::C
class C2 < ::RBS::RuntimePrototypeTest::TestForOverrideModuleName::C
end
module M
Expand Down Expand Up @@ -341,9 +341,9 @@ def test_for_type_parameters

assert_write p.decls, <<~RBS
module RBS
class RuntimePrototypeTest < Test::Unit::TestCase
class RuntimePrototypeTest < ::Test::Unit::TestCase
module TestForTypeParameters
class C < Hash[untyped, untyped]
class C < ::Hash[untyped, untyped]
end
class C2
Expand Down Expand Up @@ -372,7 +372,7 @@ def test_for_initialize_type

assert_write p.decls, <<~RBS
module RBS
class RuntimePrototypeTest < Test::Unit::TestCase
class RuntimePrototypeTest < ::Test::Unit::TestCase
class TestForInitialize
private
Expand Down Expand Up @@ -400,7 +400,7 @@ def test_for_yield

assert_write p.decls, <<~RBS
module RBS
class RuntimePrototypeTest < Test::Unit::TestCase
class RuntimePrototypeTest < ::Test::Unit::TestCase
class TestForYield
public
Expand Down

0 comments on commit 0041bc6

Please sign in to comment.