diff --git a/lib/rbs/namespace.rb b/lib/rbs/namespace.rb index 67b2ef3f9..e8f20bd7c 100644 --- a/lib/rbs/namespace.rb +++ b/lib/rbs/namespace.rb @@ -119,6 +119,7 @@ def ascend module Kernel def Namespace(name) + warn "Kernel#Namespace() is deprecated. Use RBS::Namespace.parse instead.", category: :deprecated RBS::Namespace.parse(name) end end diff --git a/sig/namespace.rbs b/sig/namespace.rbs index 3ab23affd..cbb329468 100644 --- a/sig/namespace.rbs +++ b/sig/namespace.rbs @@ -141,7 +141,6 @@ module RBS end module Kernel - # Parses given string and returns Namespace. - # - def Namespace: (String) -> RBS::Namespace + # Deprecated: Use `RBS::Namespace.parse` instead + %a{steep:deprecated} def Namespace: (String) -> RBS::Namespace end diff --git a/test/rbs/signature_parsing_test.rb b/test/rbs/signature_parsing_test.rb index 95e40805c..172188834 100644 --- a/test/rbs/signature_parsing_test.rb +++ b/test/rbs/signature_parsing_test.rb @@ -2153,7 +2153,7 @@ class Foo end use.clauses[1].tap do |clause| - assert_equal Namespace("RBS::AST::Declarations::"), clause.namespace + assert_equal RBS::Namespace.parse("RBS::AST::Declarations::"), clause.namespace assert_equal "RBS::AST::Declarations::", clause.location[:namespace].source assert_equal "*", clause.location[:star].source end diff --git a/test/rbs/use_map_test.rb b/test/rbs/use_map_test.rb index 7113a2ddb..32f8bfad5 100644 --- a/test/rbs/use_map_test.rb +++ b/test/rbs/use_map_test.rb @@ -36,7 +36,7 @@ def test_import_single_clause end def test_import_wildcard_clause - map.build_map(Use::WildcardClause.new(namespace: Namespace("Foo::"), location: nil)) + map.build_map(Use::WildcardClause.new(namespace: RBS::Namespace.parse("Foo::"), location: nil)) assert_equal TypeName("::Foo::M"), map.resolve?(TypeName("M")) assert_equal TypeName("::Foo::_I"), map.resolve?(TypeName("_I"))