Skip to content

Commit 51d27db

Browse files
committed
Replace deterministic untyped return types with concrete types
Several methods were typed `-> untyped` even though their return value is determined by the implementation. Give them concrete types: - `StringIO#putc`, `Zlib::GzipWriter#putc` -> `Numeric | String` (returns the argument) - `Zlib::GzipFile#sync=` -> `boolish` (setter returns the argument) - `MonitorMixin::ConditionVariable#wait_for_cond` / `#wait` -> `bool` - `MonitorMixin::ConditionVariable#wait_until` / `#wait_while` -> `nil` (loop expression) - `ERB#run` -> `nil`, `ERB#initialize` -> `void` - `ERB#def_method`, `ERB::DefMethod.def_erb_method` -> `Symbol`
1 parent fa84359 commit 51d27db

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

stdlib/erb/0/erb.rbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ class ERB
619619
# It's good practice to choose a variable name that begins with an underscore:
620620
# <code>'_'</code>.
621621
#
622-
def initialize: (String, ?eoutvar: String, ?trim_mode: Integer | String | NilClass) -> untyped
622+
def initialize: (String, ?eoutvar: String, ?trim_mode: Integer | String | NilClass) -> void
623623

624624
# <!-- rdoc-file=lib/erb.rb -->
625625
# Returns the Ruby code that, when executed, generates the result;
@@ -702,7 +702,7 @@ class ERB
702702
# Like #result, but prints the result string (instead of returning it);
703703
# returns `nil`.
704704
#
705-
def run: (?Binding) -> untyped
705+
def run: (?Binding) -> nil
706706

707707
# <!--
708708
# rdoc-file=lib/erb.rb
@@ -746,7 +746,7 @@ class ERB
746746
# class MyClass; include MyModule; end
747747
# MyClass.new.render('foo', 123) # => "foo 123"
748748
#
749-
def def_method: (Module, String, ?String) -> untyped
749+
def def_method: (Module, String, ?String) -> Symbol
750750

751751
# <!--
752752
# rdoc-file=lib/erb.rb
@@ -913,7 +913,7 @@ class ERB
913913
# define *methodname* as instance method of current module, using ERB object or
914914
# eRuby file
915915
#
916-
def self.def_erb_method: (String methodname, (String | ERB) erb_or_fname) -> untyped
916+
def self.def_erb_method: (String methodname, (String | ERB) erb_or_fname) -> Symbol
917917
end
918918

919919
# <!-- rdoc-file=lib/erb/util.rb -->

stdlib/monitor/0/monitor.rbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class Monitor
111111
# - wait_for_cond(p1, p2)
112112
# -->
113113
#
114-
def wait_for_cond: (::MonitorMixin::ConditionVariable, Numeric? timeout) -> untyped
114+
def wait_for_cond: (::MonitorMixin::ConditionVariable, Numeric? timeout) -> bool
115115
end
116116

117117
# <!-- rdoc-file=ext/monitor/lib/monitor.rb -->
@@ -334,23 +334,23 @@ class MonitorMixin::ConditionVariable
334334
# If `timeout` is given, this method returns after `timeout` seconds passed,
335335
# even if no other thread doesn't signal.
336336
#
337-
def wait: (?Numeric? timeout) -> untyped
337+
def wait: (?Numeric? timeout) -> bool
338338

339339
# <!--
340340
# rdoc-file=ext/monitor/lib/monitor.rb
341341
# - wait_until()
342342
# -->
343343
# Calls wait repeatedly until the given block yields a truthy value.
344344
#
345-
def wait_until: () { () -> boolish } -> untyped
345+
def wait_until: () { () -> boolish } -> nil
346346

347347
# <!--
348348
# rdoc-file=ext/monitor/lib/monitor.rb
349349
# - wait_while()
350350
# -->
351351
# Calls wait repeatedly while the given block yields a truthy value.
352352
#
353-
def wait_while: () { () -> boolish } -> untyped
353+
def wait_while: () { () -> boolish } -> nil
354354

355355
private
356356

stdlib/stringio/0/stringio.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ class StringIO
12711271
# -->
12721272
# See IO#putc.
12731273
#
1274-
def putc: (Numeric | String arg0) -> untyped
1274+
def putc: (Numeric | String arg0) -> (Numeric | String)
12751275

12761276
def puts: (*untyped arg0) -> nil
12771277

stdlib/zlib/0/gzip_file.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ module Zlib
143143
# `flush` method. While `sync` mode is `true`, the compression ratio decreases
144144
# sharply.
145145
#
146-
def sync=: (boolish) -> untyped
146+
def sync=: (boolish) -> boolish
147147

148148
# <!--
149149
# rdoc-file=ext/zlib/zlib.c

stdlib/zlib/0/gzip_writer.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ module Zlib
125125
# -->
126126
# Same as IO.
127127
#
128-
def putc: (Numeric | String arg0) -> untyped
128+
def putc: (Numeric | String arg0) -> (Numeric | String)
129129

130130
# <!--
131131
# rdoc-file=ext/zlib/zlib.c

0 commit comments

Comments
 (0)