Skip to content

Commit c8b02bf

Browse files
kssssoutaro
authored andcommitted
Deprecate Kernel#Namespace
Namespace functionality will be added in Ruby4. If added, `Namespace()` is likely to create confusion.
1 parent 1877ae5 commit c8b02bf

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/rbs/namespace.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def ascend
119119

120120
module Kernel
121121
def Namespace(name)
122+
warn "Kernel#Namespace() is deprecated. Use RBS::Namespace.parse instead.", category: :deprecated
122123
RBS::Namespace.parse(name)
123124
end
124125
end

sig/namespace.rbs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ module RBS
141141
end
142142

143143
module Kernel
144-
# Parses given string and returns Namespace.
145-
#
146-
def Namespace: (String) -> RBS::Namespace
144+
# Deprecated: Use `RBS::Namespace.parse` instead
145+
%a{steep:deprecated} def Namespace: (String) -> RBS::Namespace
147146
end

test/rbs/signature_parsing_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,7 @@ class Foo
21532153
end
21542154

21552155
use.clauses[1].tap do |clause|
2156-
assert_equal Namespace("RBS::AST::Declarations::"), clause.namespace
2156+
assert_equal RBS::Namespace.parse("RBS::AST::Declarations::"), clause.namespace
21572157
assert_equal "RBS::AST::Declarations::", clause.location[:namespace].source
21582158
assert_equal "*", clause.location[:star].source
21592159
end

test/rbs/use_map_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_import_single_clause
3636
end
3737

3838
def test_import_wildcard_clause
39-
map.build_map(Use::WildcardClause.new(namespace: Namespace("Foo::"), location: nil))
39+
map.build_map(Use::WildcardClause.new(namespace: RBS::Namespace.parse("Foo::"), location: nil))
4040

4141
assert_equal TypeName("::Foo::M"), map.resolve?(TypeName("M"))
4242
assert_equal TypeName("::Foo::_I"), map.resolve?(TypeName("_I"))

0 commit comments

Comments
 (0)