Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super class should be absolute paths. #1415

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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