-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Run source-typer on crystal standard library, give or take #15682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,28 +48,28 @@ class Channel(T) | |
end | ||
|
||
# :nodoc: | ||
def self.select(*ops : SelectAction) | ||
def self.select(*ops : SelectAction) : Tuple(Int32, String) | Tuple(Int32, Nil) | Tuple(Int32, Bool | String) | Tuple(Int32, String | Nil) | Tuple(Int32, Bool | String | Nil) | Tuple(Int32, Int32) | ||
self.select ops | ||
end | ||
|
||
# :nodoc: | ||
def self.select(ops : Indexable(SelectAction)) | ||
def self.select(ops : Indexable(SelectAction)) : Tuple(Int32, Int32) | Tuple(Int32, Nil) | Tuple(Int32, String) | Tuple(Int32, Bool | String) | Tuple(Int32, String | Nil) | Tuple(Int32, Bool | String | Nil) | Tuple(Int32, Bool | Nil) | Tuple(Int32, Int32 | Nil) | ||
i, m = select_impl(ops, false) | ||
raise "BUG: Blocking select returned not ready status" if m.is_a?(NotReady) | ||
return i, m | ||
end | ||
|
||
# :nodoc: | ||
def self.non_blocking_select(*ops : SelectAction) | ||
def self.non_blocking_select(*ops : SelectAction) : Tuple(Int32, Channel::NotReady | String) | Tuple(Int32, Bool | Channel::NotReady | String) | Tuple(Int32, Channel::NotReady | String | Nil) | Tuple(Int32, Channel::NotReady | Nil) | ||
self.non_blocking_select ops | ||
end | ||
|
||
# :nodoc: | ||
def self.non_blocking_select(ops : Indexable(SelectAction)) | ||
def self.non_blocking_select(ops : Indexable(SelectAction)) : Tuple(Int32, Channel::NotReady | String) | Tuple(Int32, Bool | Channel::NotReady | String) | Tuple(Int32, Channel::NotReady | String | Nil) | Tuple(Int32, Channel::NotReady | Nil) | Tuple(Int32, Bool | Channel::NotReady) | Tuple(Int32, Bool | Channel::NotReady | String | Nil) | Tuple(Int32, Channel::NotReady | Exception | Nil) | ||
select_impl(ops, true) | ||
end | ||
|
||
private def self.select_impl(ops : Indexable(SelectAction), non_blocking) | ||
private def self.select_impl(ops : Indexable(SelectAction), non_blocking : Bool) : Tuple(Int32, Channel::NotReady | Int32) | Tuple(Int32, Channel::NotReady | Nil) | Tuple(Int32, Channel::NotReady | String) | Tuple(Int32, Bool | Channel::NotReady | String) | Tuple(Int32, Channel::NotReady | String | Nil) | Tuple(Int32, Bool | Channel::NotReady | String | Nil) | Tuple(Int32, Bool | Channel::NotReady) | Tuple(Int32, Bool | Channel::NotReady | Nil) | Tuple(Int32, Channel::NotReady | Int32 | Nil) | Tuple(Int32, Channel::NotReady | Exception | Nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Urgh, tuples are nice but they quickly create lots of types. It might be interesting to introduce a type, here 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seeing the size of the union is a good indication there's confusion on what's expected of this method. Could also be a good opportunity to see why some of the types show up like this as well. |
||
# ops_locks is a duplicate of ops that can be sorted without disturbing the | ||
# index positions of ops | ||
if ops.responds_to?(:unstable_sort_by!) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The static arrays are interesting: they outline that the method should really just take a slice, and there are opportunities for optimizations.
Even the string in the other methods are interesting. There could be a specific overload that would call the slice method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we should be able to express a type restriction for types that have a
#to_slice : Bytes
method (cf. #934).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about runtime optimizations because private methods are typically inlined anyway, so the static array here likely won't be copied around.
But for sure the compiler would have an easier time if it has to deal with only one method accepting
Bytes
instead of a multitude of differentStaticArray
instance types.