Skip to content

Commit

Permalink
Merge pull request #1490 from ksss/runtime-const-name
Browse files Browse the repository at this point in the history
[prototype runtime] Const name should be absolute
  • Loading branch information
soutaro authored Sep 5, 2023
2 parents f8e43c3 + f1c2c6a commit a76d118
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
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

0 comments on commit a76d118

Please sign in to comment.