rbs 2.2.2 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +4 -0
  3. data/.github/workflows/comments.yml +2 -2
  4. data/.github/workflows/ruby.yml +19 -1
  5. data/.gitignore +0 -1
  6. data/CHANGELOG.md +66 -0
  7. data/Gemfile +2 -1
  8. data/Gemfile.lock +117 -0
  9. data/Rakefile +1 -1
  10. data/core/dir.rbs +1 -1
  11. data/core/enumerator.rbs +1 -1
  12. data/core/false_class.rbs +1 -1
  13. data/core/integer.rbs +4 -4
  14. data/core/io/wait.rbs +1 -1
  15. data/core/module.rbs +21 -2
  16. data/core/nil_class.rbs +7 -5
  17. data/core/object.rbs +9 -0
  18. data/core/trace_point.rbs +42 -3
  19. data/core/true_class.rbs +1 -1
  20. data/ext/rbs_extension/constants.c +1 -1
  21. data/ext/rbs_extension/location.c +1 -1
  22. data/ext/rbs_extension/parser.c +9 -4
  23. data/ext/rbs_extension/parserstate.c +2 -2
  24. data/ext/rbs_extension/unescape.c +2 -2
  25. data/lib/rbs/ast/members.rb +2 -1
  26. data/lib/rbs/collection/installer.rb +4 -1
  27. data/lib/rbs/definition_builder/ancestor_builder.rb +5 -2
  28. data/lib/rbs/definition_builder/method_builder.rb +1 -1
  29. data/lib/rbs/definition_builder.rb +2 -2
  30. data/lib/rbs/environment.rb +24 -12
  31. data/lib/rbs/locator.rb +24 -15
  32. data/lib/rbs/prototype/rb.rb +17 -6
  33. data/lib/rbs/resolver/constant_resolver.rb +201 -0
  34. data/lib/rbs/resolver/type_name_resolver.rb +55 -0
  35. data/lib/rbs/type_name.rb +15 -0
  36. data/lib/rbs/version.rb +1 -1
  37. data/lib/rbs.rb +2 -0
  38. data/schema/members.json +4 -1
  39. data/sig/environment.rbs +28 -21
  40. data/sig/environment_loader.rbs +23 -23
  41. data/sig/locator.rbs +2 -0
  42. data/sig/manifest.yaml +8 -0
  43. data/sig/resolver/constant_resolver.rbs +93 -0
  44. data/sig/resolver/context.rbs +34 -0
  45. data/sig/resolver/type_name_resolver.rbs +31 -0
  46. data/sig/typename.rbs +9 -3
  47. data/stdlib/bigdecimal/0/big_decimal.rbs +135 -0
  48. data/stdlib/erb/0/erb.rbs +237 -0
  49. data/stdlib/optparse/0/optparse.rbs +20 -18
  50. data/stdlib/prime/0/prime.rbs +115 -4
  51. data/stdlib/rubygems/0/version.rbs +159 -1
  52. data/steep/Gemfile.lock +13 -15
  53. metadata +10 -3
data/sig/environment.rbs CHANGED
@@ -2,32 +2,40 @@ module RBS
2
2
  class Environment
3
3
  type module_decl = AST::Declarations::Class | AST::Declarations::Module
4
4
 
5
- interface _WithContext
6
- def outer: () -> Array[module_decl]
5
+ interface _ModuleOrClass
6
+ def name: () -> TypeName
7
7
 
8
- def decl: () -> untyped
8
+ def type_params: () -> Array[AST::TypeParam]
9
9
  end
10
10
 
11
- module ContextUtil : _WithContext
12
- def context: () -> Array[Namespace]
11
+ interface _NamedDecl
12
+ def name: () -> TypeName
13
+ end
14
+
15
+ module ContextUtil
16
+ def calculate_context: (Array[_NamedDecl]) -> Array[Namespace]
13
17
  end
14
18
 
15
- class MultiEntry
16
- class D[M]
19
+ class MultiEntry[M < _ModuleOrClass]
20
+ class D[M < _ModuleOrClass]
17
21
  attr_reader decl: M
18
22
  attr_reader outer: Array[module_decl]
19
23
 
20
- def initialize: (decl: module_decl, outer: Array[module_decl]) -> void
24
+ def initialize: (decl: M, outer: Array[module_decl]) -> void
21
25
 
22
26
  include ContextUtil
27
+
28
+ @context: Array[Namespace]
29
+
30
+ def context: () -> Array[Namespace]
23
31
  end
24
32
 
25
33
  attr_reader name: TypeName
26
- attr_reader decls: Array[untyped]
34
+ attr_reader decls: Array[D[M]]
27
35
 
28
36
  def initialize: (name: TypeName) -> void
29
37
 
30
- def insert: (decl: module_decl, outer: Array[module_decl]) -> void
38
+ def insert: (decl: M, outer: Array[module_decl]) -> void
31
39
 
32
40
  def validate_type_params: () -> void
33
41
 
@@ -35,29 +43,28 @@ module RBS
35
43
 
36
44
  def type_params: () -> Array[AST::TypeParam]
37
45
 
38
- def primary: () -> D[module_decl]
46
+ def primary: () -> D[M]
39
47
  end
40
48
 
41
- class ModuleEntry < MultiEntry
42
- attr_reader decls: Array[MultiEntry::D[AST::Declarations::Module]]
43
- attr_reader primary: MultiEntry::D[AST::Declarations::Module]
44
-
49
+ class ModuleEntry < MultiEntry[AST::Declarations::Module]
45
50
  def self_types: () -> Array[AST::Declarations::Module::Self]
46
51
  end
47
52
 
48
- class ClassEntry < MultiEntry
49
- attr_reader decls: Array[MultiEntry::D[AST::Declarations::Class]]
50
- attr_reader primary: MultiEntry::D[AST::Declarations::Class]
53
+ class ClassEntry < MultiEntry[AST::Declarations::Class]
51
54
  end
52
55
 
53
56
  class SingleEntry[N, D]
54
- include ContextUtil
55
-
56
57
  attr_reader name: N
57
58
  attr_reader decl: D
58
59
  attr_reader outer: Array[module_decl]
59
60
 
60
61
  def initialize: (name: N, decl: D, outer: Array[module_decl]) -> void
62
+
63
+ include ContextUtil
64
+
65
+ @context: Array[Namespace]
66
+
67
+ def context: () -> Array[Namespace]
61
68
  end
62
69
 
63
70
  # Top level declarations.
@@ -75,7 +82,7 @@ module RBS
75
82
 
76
83
  def self.from_loader: (EnvironmentLoader) -> Environment
77
84
 
78
- def cache_name: [Key, D] (Hash[Key, SingleEntry[Key, D]] cache, name: Key, decl: D, outer: Array[module_decl]) -> SingleEntry[Key, D]
85
+ def cache_name: [N, D] (Hash[N, SingleEntry[N, D]] cache, name: N, decl: D, outer: Array[module_decl]) -> SingleEntry[N, D]
79
86
 
80
87
  def insert_decl: (AST::Declarations::t, outer: Array[module_decl], namespace: Namespace) -> void
81
88
 
@@ -1,26 +1,26 @@
1
1
  module RBS
2
2
  # EnvironmentLoader is an object to load RBS files from filesystem.
3
- #
3
+ #
4
4
  # Set up your configuration through repository and `#add` method.
5
- #
5
+ #
6
6
  # # Set up the repository to load library RBSs from.
7
7
  # repo = RBS::Repository.default
8
8
  # repo.add(Pathname("vendor/rbs/gem-rbs"))
9
9
  # repo.add(Pathname("vendor/rbs/internal-rbs"))
10
- #
10
+ #
11
11
  # loader = RBS::EnvironmentLoader.new(repository: repo)
12
- #
12
+ #
13
13
  # # Add libraries to load RBS files.
14
14
  # loader.add(library: "minitest")
15
15
  # loader.add(library: "rbs", version: "1.0.0")
16
- #
16
+ #
17
17
  # # Add dirs to load RBS files from.
18
18
  # loader.add(path: Pathname("sig"))
19
- #
19
+ #
20
20
  # # Load RBSs into an environment.
21
21
  # environment = RBS::Environment.new()
22
22
  # loader.load(env: environment)
23
- #
23
+ #
24
24
  class EnvironmentLoader
25
25
  class UnknownLibraryError < StandardError
26
26
  attr_reader library: Library
@@ -44,37 +44,37 @@ module RBS
44
44
  attr_reader dirs: Array[Pathname]
45
45
 
46
46
  # The source where the RBS comes from.
47
- #
47
+ #
48
48
  # `:core` means it is part of core library.
49
49
  # `Library` means it is from library.
50
50
  # `Pathname` means it is loaded from a directory.
51
- #
51
+ #
52
52
  type source = :core
53
53
  | Library
54
54
  | Pathname
55
55
 
56
56
  # Accepts two optional keyword arguments.
57
- #
57
+ #
58
58
  # `core_root` is the path to the directory with RBSs for core classes.
59
59
  # The default value is the core library included in RBS gem. (EnvironmentLoader::DEFAULT_CORE_ROOT)
60
60
  # Passing `nil` means it skips loading core class definitions.
61
- #
61
+ #
62
62
  # `repository` is the repository for library classes.
63
63
  # The default value is repository only with stdlib classes. (Repository.new)
64
- #
64
+ #
65
65
  def initialize: (?core_root: Pathname?, ?repository: Repository) -> void
66
-
66
+
67
67
  # Add a path or library to load RBSs from.
68
- #
68
+ #
69
69
  # `path` can be a file or a directory.
70
70
  # All `.rbs` files from the given directory will be loaded.
71
71
  # Specifying a file will load the file regardless the extension of the file is.
72
- #
72
+ #
73
73
  # `library` can be a name of a gem.
74
74
  # Specifying `nil` to `version` will load any version available.
75
75
  # It first tries to load RBS files from gem with specified version.
76
76
  # If RBS files cannot be found in the gem, it tries to load RBSs from repository.
77
- #
77
+ #
78
78
  def add: (path: Pathname) -> void
79
79
  | (library: String, version: String?) -> void
80
80
 
@@ -82,26 +82,26 @@ module RBS
82
82
  def add_collection: (Collection::Config collection_config) -> void
83
83
 
84
84
  # This is helper function to test if RBS for a library is available or not.
85
- #
85
+ #
86
86
  def has_library?: (library: String, version: String?) -> bool
87
87
 
88
88
  # Add all declarations to environment.
89
- #
89
+ #
90
90
  # Raises `UnknownLibraryError` if RBS cannot be loaded from a library.
91
- #
91
+ #
92
92
  # Returns an array of tuples of the declaration, path to the file, and the source.
93
- #
93
+ #
94
94
  def load: (env: Environment) -> Array[[AST::Declarations::t, Pathname, source]]
95
95
 
96
96
  # Returns a pair of spec and path for a gem with RBS.
97
97
  # Returns nil if the gem is not installed, or the gem doesn't provide RBS.
98
- #
98
+ #
99
99
  def self.gem_sig_path: (String name, String? version) -> [Gem::Specification, Pathname]?
100
100
 
101
101
  def each_decl: () { (AST::Declarations::t, Buffer, source, Pathname) -> void } -> void
102
-
102
+
103
103
  def each_dir: { (source, Pathname) -> void } -> void
104
-
104
+
105
105
  def each_file: (Pathname path, immediate: boolish, skip_hidden: boolish) { (Pathname) -> void } -> void
106
106
  end
107
107
  end
data/sig/locator.rbs CHANGED
@@ -37,6 +37,8 @@ module RBS
37
37
 
38
38
  def find_in_type: (Integer pos, type: Types::t, array: Array[component]) -> bool
39
39
 
40
+ def find_in_type_param: (Integer pos, type_param: AST::TypeParam, array: Array[component]) -> bool
41
+
40
42
  def find_in_loc: (Integer pos, location: Location[untyped, untyped]?, array: Array[component]) -> bool
41
43
 
42
44
  def test_loc: (Integer pos, location: Location[untyped, untyped]?) -> bool
data/sig/manifest.yaml ADDED
@@ -0,0 +1,8 @@
1
+ dependencies:
2
+ - name: logger
3
+ - name: set
4
+ - name: pathname
5
+ - name: json
6
+ - name: optparse
7
+ - name: rubygems
8
+ - name: tsort
@@ -0,0 +1,93 @@
1
+ module RBS
2
+ module Resolver
3
+ class ConstantResolver
4
+ # Table stores the set of immediate child constants of a module.
5
+ #
6
+ # ```rb
7
+ # table = RBS::ConstantResolver::Table.new(env)
8
+ #
9
+ # table.children(TypeName("::Object")) # -> { ... } Returns a hash of name and constants.
10
+ # table.children(TypeName("::File::PATH_SEPARATOR")) # -> nil Returns nil because the constant is not a module.
11
+ #
12
+ # table.toplevel # -> { ... } Returns a hash of top level constants.
13
+ # ```
14
+ #
15
+ # The `#toplevel` is incompatible with Ruby.
16
+ # All constants in Ruby are defined under `Object`, and they are accessed with `::` (Colon3) operator.
17
+ # RBS is different.
18
+ # `::` constants are _toplevel_ constants, and they are not defined under `::Object`.
19
+ #
20
+ # The behavior is simulated in `ConstantResolver`.
21
+ #
22
+ class Table
23
+ attr_reader children_table: Hash[TypeName, Hash[Symbol, Constant]?]
24
+ attr_reader constants_table: Hash[TypeName, Constant]
25
+ attr_reader toplevel: Hash[Symbol, Constant]
26
+
27
+ def initialize: (Environment) -> void
28
+
29
+ def constant: (TypeName constant_name) -> Constant?
30
+
31
+ # Returns a set of constants defined under `module_name`.
32
+ # Returns `nil` if there is no module with given `module_name`.
33
+ #
34
+ def children: (TypeName module_name) -> Hash[Symbol, Constant]?
35
+
36
+ private
37
+
38
+ def constant_of_module: (TypeName name, Environment::ClassEntry | Environment::ModuleEntry) -> Constant
39
+
40
+ def constant_of_constant: (TypeName name, Environment::SingleEntry[TypeName, AST::Declarations::Constant]) -> Constant
41
+ end
42
+
43
+ attr_reader builder: DefinitionBuilder
44
+ attr_reader table: Table
45
+ attr_reader context_constants_cache: Hash[context, Hash[Symbol, Constant]?]
46
+ attr_reader child_constants_cache: Hash[TypeName, Hash[Symbol, Constant]]
47
+
48
+ def initialize: (builder: DefinitionBuilder) -> void
49
+
50
+ # Resolves to `Constant` with given constant name `name` and `context`.
51
+ # Returns `nil` if the constant cannot be resolved from the context.
52
+ #
53
+ def resolve: (Symbol name, context: context) -> Constant?
54
+
55
+ # Returns the available all constants from `context`.
56
+ #
57
+ # Returns `nil` when the `context` is invalid.
58
+ def constants: (context) -> Hash[Symbol, Constant]?
59
+
60
+ # Resolves the module_name and constant name to `Constant`
61
+ #
62
+ # ```ruby
63
+ # A::B
64
+ # ^ <- module_name
65
+ # ^ <- constant_name
66
+ # ```
67
+ #
68
+ # Find the
69
+ def resolve_child: (TypeName module_name, Symbol constant_name) -> Constant?
70
+
71
+ # Returns the table of all constants accessible with `::` (colon2) operator.
72
+ #
73
+ # * The constants under the module are included.
74
+ # * The constants under the ancestor modules are included.
75
+ # * The constants under the `::Object` class are not included.
76
+ # * The top level constants are not included.
77
+ #
78
+ def children: (TypeName module_name) -> Hash[Symbol, Constant]
79
+
80
+ private
81
+
82
+ def load_context_constants: (context) -> void
83
+
84
+ def load_child_constants: (TypeName) -> void
85
+
86
+ def constants_from_context: (context, constants: Hash[Symbol, Constant]) -> bool
87
+
88
+ def constants_from_ancestors: (TypeName, constants: Hash[Symbol, Constant]) -> void
89
+
90
+ def constants_itself: (context, constants: Hash[Symbol, Constant]) -> void
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,34 @@
1
+ module RBS
2
+ module Resolver
3
+ # `context` represents the module nesting structure.
4
+ #
5
+ # - `nil` means toplevel
6
+ # - A 2-tuple represents parent and the most inner module
7
+ # - `TypeName` is for a module
8
+ # - `false` is for unknown module
9
+ #
10
+ # Note that the `TypeName` must be an absolute type name.
11
+ #
12
+ # The following Ruby code has context of `[[nil, TypeName("::Foo")], false]` where
13
+ #
14
+ # * `Foo` is a class defined in RBS file
15
+ # * `Bar` is not defined in RBS files
16
+ #
17
+ # ```ruby
18
+ # class Foo
19
+ # module Bar
20
+ # # Context here
21
+ # end
22
+ # end
23
+ # ```
24
+ #
25
+ # The unknown module (`false`) appears only in Ruby code.
26
+ # RBS modules/classes are always exists (or defines new module).
27
+ # Nesting a unknown module cannot happen in RBS.
28
+ #
29
+ # In Ruby this happens when the module/class is not declared in RBS files.
30
+ #
31
+ type context = [context, TypeName | false]
32
+ | nil
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ module RBS
2
+ module Resolver
3
+ # TypeNameResolver resolves given relative type name to absolute type name under a module nesting context.
4
+ #
5
+ # The type name resolution doesn't take account of ancestors of modules.
6
+ # It just ignores included modules and super classes.
7
+ #
8
+ class TypeNameResolver
9
+ type query = [TypeName, context]
10
+
11
+ def initialize: (Environment) -> void
12
+
13
+ # Translates given type name to absolute type name.
14
+ # Returns `nil` if cannot find associated type name.
15
+ #
16
+ def resolve: (TypeName, context: context) -> TypeName?
17
+
18
+ private
19
+
20
+ attr_reader all_names: Set[TypeName]
21
+
22
+ attr_reader cache: Hash[query, TypeName?]
23
+
24
+ def has_name?: (TypeName) -> TypeName?
25
+
26
+ def try_cache: (query) { () -> TypeName? } -> TypeName?
27
+
28
+ def resolve_in: (TypeName, context) -> TypeName?
29
+ end
30
+ end
31
+ end
data/sig/typename.rbs CHANGED
@@ -56,11 +56,17 @@ module RBS
56
56
 
57
57
  # Returns a new type name with a namespace appended to given namespace.
58
58
  #
59
- # TypeName("Hello").with_prefix(Namespace("World")) # => World::Hello
60
- # TypeName("Foo::Bar").with_prefix(Namespace("::Hello")) # => ::Hello::Foo::Bar
61
- # TypeName("::A::B").with_prefix(Namespace("C")) # => ::A::B
59
+ # ```rb
60
+ # TypeName("Hello").with_prefix(Namespace("World")) # => World::Hello
61
+ # TypeName("Foo::Bar").with_prefix(Namespace("::Hello")) # => ::Hello::Foo::Bar
62
+ # TypeName("::A::B").with_prefix(Namespace("C")) # => ::A::B
63
+ # ```
62
64
  #
63
65
  def with_prefix: (Namespace namespace) -> TypeName
66
+
67
+ def +: (TypeName) -> TypeName
68
+
69
+ def split: () -> Array[Symbol]
64
70
  end
65
71
  end
66
72
 
@@ -1187,6 +1187,19 @@ class BigDecimal < Numeric
1187
1187
  #
1188
1188
  def zero?: () -> bool
1189
1189
 
1190
+ # <!--
1191
+ # rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
1192
+ # - a.to_d -> bigdecimal
1193
+ # -->
1194
+ # Returns self.
1195
+ #
1196
+ # require 'bigdecimal/util'
1197
+ #
1198
+ # d = BigDecimal("3.14")
1199
+ # d.to_d # => 0.314e1
1200
+ #
1201
+ def to_d: () -> BigDecimal
1202
+
1190
1203
  private
1191
1204
 
1192
1205
  def initialize_copy: (self) -> self
@@ -1378,3 +1391,125 @@ module Kernel
1378
1391
  #
1379
1392
  def self?.BigDecimal: (real | string | BigDecimal initial, ?int digits, ?exception: bool) -> BigDecimal
1380
1393
  end
1394
+
1395
+ %a{annotate:rdoc:skip}
1396
+ class Integer
1397
+ # <!--
1398
+ # rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
1399
+ # - int.to_d -> bigdecimal
1400
+ # -->
1401
+ # Returns the value of `int` as a BigDecimal.
1402
+ #
1403
+ # require 'bigdecimal'
1404
+ # require 'bigdecimal/util'
1405
+ #
1406
+ # 42.to_d # => 0.42e2
1407
+ #
1408
+ # See also BigDecimal::new.
1409
+ #
1410
+ def to_d: () -> BigDecimal
1411
+ end
1412
+
1413
+ %a{annotate:rdoc:skip}
1414
+ class Float
1415
+ # <!--
1416
+ # rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
1417
+ # - float.to_d -> bigdecimal
1418
+ # - float.to_d(precision) -> bigdecimal
1419
+ # -->
1420
+ # Returns the value of `float` as a BigDecimal. The `precision` parameter is
1421
+ # used to determine the number of significant digits for the result (the default
1422
+ # is Float::DIG).
1423
+ #
1424
+ # require 'bigdecimal'
1425
+ # require 'bigdecimal/util'
1426
+ #
1427
+ # 0.5.to_d # => 0.5e0
1428
+ # 1.234.to_d(2) # => 0.12e1
1429
+ #
1430
+ # See also BigDecimal::new.
1431
+ #
1432
+ def to_d: (?Integer precision) -> BigDecimal
1433
+ end
1434
+
1435
+ %a{annotate:rdoc:skip}
1436
+ class String
1437
+ # <!--
1438
+ # rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
1439
+ # - str.to_d -> bigdecimal
1440
+ # -->
1441
+ # Returns the result of interpreting leading characters in `str` as a
1442
+ # BigDecimal.
1443
+ #
1444
+ # require 'bigdecimal'
1445
+ # require 'bigdecimal/util'
1446
+ #
1447
+ # "0.5".to_d # => 0.5e0
1448
+ # "123.45e1".to_d # => 0.12345e4
1449
+ # "45.67 degrees".to_d # => 0.4567e2
1450
+ #
1451
+ # See also BigDecimal::new.
1452
+ #
1453
+ def to_d: () -> BigDecimal
1454
+ end
1455
+
1456
+ %a{annotate:rdoc:skip}
1457
+ class Rational
1458
+ # <!--
1459
+ # rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
1460
+ # - rat.to_d(precision) -> bigdecimal
1461
+ # -->
1462
+ # Returns the value as a BigDecimal.
1463
+ #
1464
+ # The required `precision` parameter is used to determine the number of
1465
+ # significant digits for the result.
1466
+ #
1467
+ # require 'bigdecimal'
1468
+ # require 'bigdecimal/util'
1469
+ #
1470
+ # Rational(22, 7).to_d(3) # => 0.314e1
1471
+ #
1472
+ # See also BigDecimal::new.
1473
+ #
1474
+ def to_d: (Integer precision) -> BigDecimal
1475
+ end
1476
+
1477
+ %a{annotate:rdoc:skip}
1478
+ class Complex
1479
+ # <!--
1480
+ # rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
1481
+ # - cmp.to_d -> bigdecimal
1482
+ # - cmp.to_d(precision) -> bigdecimal
1483
+ # -->
1484
+ # Returns the value as a BigDecimal.
1485
+ #
1486
+ # The `precision` parameter is required for a rational complex number. This
1487
+ # parameter is used to determine the number of significant digits for the
1488
+ # result.
1489
+ #
1490
+ # require 'bigdecimal'
1491
+ # require 'bigdecimal/util'
1492
+ #
1493
+ # Complex(0.1234567, 0).to_d(4) # => 0.1235e0
1494
+ # Complex(Rational(22, 7), 0).to_d(3) # => 0.314e1
1495
+ #
1496
+ # See also BigDecimal::new.
1497
+ #
1498
+ def to_d: (*untyped args) -> BigDecimal
1499
+ end
1500
+
1501
+ %a{annotate:rdoc:skip}
1502
+ class NilClass
1503
+ # <!--
1504
+ # rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
1505
+ # - nil.to_d -> bigdecimal
1506
+ # -->
1507
+ # Returns nil represented as a BigDecimal.
1508
+ #
1509
+ # require 'bigdecimal'
1510
+ # require 'bigdecimal/util'
1511
+ #
1512
+ # nil.to_d # => 0.0
1513
+ #
1514
+ def to_d: () -> BigDecimal
1515
+ end