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

[prototype runtime] Const name should be absolute #1490

Merged
merged 1 commit into from
Sep 5, 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
4 changes: 2 additions & 2 deletions lib/rbs/prototype/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def generate_constants(mod, decls)
when ENV
Types::ClassInstance.new(name: TypeName("::RBS::Unnamed::ENVClass"), args: [], location: nil)
else
value_type_name = to_type_name(const_name!(value.class))
value_type_name = to_type_name(const_name!(value.class), full_name: true).absolute!
args = type_args(value_type_name)
Types::ClassInstance.new(name: value_type_name, args: args, location: nil)
end
Expand Down Expand Up @@ -531,7 +531,7 @@ def ensure_outer_module_declarations(mod)
# Insert AST::Declarations if declarations are not added previously
unless outer_decl
outer_module or raise

if outer_module.is_a?(Class)
outer_decl = AST::Declarations::Class.new(
name: to_type_name(outer_module_name),
Expand Down
17 changes: 12 additions & 5 deletions test/rbs/runtime_prototype_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def foo: (untyped foo, ?untyped bar, *untyped baz, untyped a, b: untyped, ?c: un

def a: () -> untyped

NAME: String
NAME: ::String
end
end
end
Expand Down Expand Up @@ -155,7 +155,7 @@ def foo: (untyped foo, ?untyped bar, *untyped baz, untyped a, b: untyped, ?c: un

def a: () -> untyped

NAME: String
NAME: ::String
end
end
end
Expand Down Expand Up @@ -314,7 +314,7 @@ def self.name: () -> untyped

def self.to_s: () -> untyped

INSTANCE: C
INSTANCE: ::RBS::RuntimePrototypeTest::TestForOverrideModuleName::C
end

class C2 < ::RBS::RuntimePrototypeTest::TestForOverrideModuleName::C
Expand All @@ -325,7 +325,7 @@ def self.name: () -> untyped

def self.to_s: () -> untyped

X: Integer
X: ::Integer
end
end
end
Expand Down Expand Up @@ -365,7 +365,7 @@ class C2
end

module M
HASH: Hash[untyped, untyped]
HASH: ::Hash[untyped, untyped]
end
end
end
Expand Down Expand Up @@ -534,8 +534,13 @@ class TestTypeParams
end

class Unnamed
module Name
class Space
end
end
A = ARGF
B = ENV
D = Name::Space.new
end

def test_unnamed
Expand All @@ -549,6 +554,8 @@ class Unnamed
A: ::RBS::Unnamed::ARGFClass

B: ::RBS::Unnamed::ENVClass

D: ::RBS::RuntimePrototypeTest::Unnamed::Name::Space
end
end
end
Expand Down