-
Notifications
You must be signed in to change notification settings - Fork 216
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
Update Symbol #1930
Merged
Merged
Update Symbol #1930
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,9 +131,7 @@ class Symbol | |
# Symbol.all_symbols.size # => 9334 | ||
# Symbol.all_symbols.take(3) # => [:!, :"\"", :"#"] | ||
# | ||
def self.all_symbols: () -> ::Array[Symbol] | ||
|
||
public | ||
def self.all_symbols: () -> Array[Symbol] | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -152,21 +150,21 @@ class Symbol | |
# | ||
# Related: String#<=>. | ||
# | ||
def <=>: (Symbol other) -> Integer | ||
| (untyped other) -> Integer? | ||
def <=>: (Symbol object) -> (-1 | 0 | 1) | ||
| (untyped) -> (-1 | 0 | 1)? | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
# - symbol == object -> true or false | ||
# --> | ||
# Returns `true` if `object` is the same object as `self`, `false` otherwise. | ||
# | ||
def ==: (untyped obj) -> bool | ||
def ==: (untyped object) -> bool | ||
|
||
# <!-- rdoc-file=string.c --> | ||
# Returns `true` if `object` is the same object as `self`, `false` otherwise. | ||
# | ||
def ===: (untyped obj) -> bool | ||
alias === == | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -176,7 +174,7 @@ class Symbol | |
# variables; see String#=~. | ||
# | ||
def =~: (Regexp regex) -> Integer? | ||
| [T] (String::_MatchAgainst[self, T] object) -> T | ||
| [T] (String::_MatchAgainst[String, T] object) -> T | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -188,12 +186,10 @@ class Symbol | |
# --> | ||
# Equivalent to `symbol.to_s[]`; see String#[]. | ||
# | ||
def []: (int index) -> String? | ||
| (int start, int length) -> String? | ||
| (Range[Integer?] range) -> String? | ||
| (Regexp regexp) -> String? | ||
| (Regexp regexp, int | String capture) -> String? | ||
| (String match_str) -> String? | ||
def []: (int start, ?int length) -> String? | ||
| (range[int?] range) -> String? | ||
| (Regexp regexp, ?MatchData::capture backref) -> String? | ||
| (String substring) -> String? | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -240,7 +236,7 @@ class Symbol | |
# | ||
# Related: Symbol#casecmp?, String#casecmp. | ||
# | ||
def casecmp: (untyped other) -> Integer? | ||
def casecmp: (untyped object) -> (-1 | 0 | 1)? | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -273,7 +269,7 @@ class Symbol | |
# | ||
# Related: Symbol#casecmp, String#casecmp?. | ||
# | ||
def casecmp?: (untyped other) -> bool? | ||
def casecmp?: (untyped object) -> bool? | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -321,7 +317,7 @@ class Symbol | |
# | ||
# Related: Symbol#inspect, Symbol#name. | ||
# | ||
def id2name: () -> String | ||
alias id2name to_s | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -340,7 +336,7 @@ class Symbol | |
# - intern() | ||
# --> | ||
# | ||
def intern: () -> Symbol | ||
alias intern to_sym | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -358,16 +354,16 @@ class Symbol | |
# Equivalent to `self.to_s.match`, including possible updates to global | ||
# variables; see String#match. | ||
# | ||
def match: (Regexp | string pattern, ?int pos) -> MatchData? | ||
| (Regexp | string pattern, ?int pos) { (MatchData) -> void } -> untyped | ||
def match: (Regexp | string pattern, ?int offset) -> MatchData? | ||
| [T] (Regexp | string pattern, ?int offset) { (MatchData matchdata) -> T } -> T? | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
# - match?(pattern, offset) -> true or false | ||
# --> | ||
# Equivalent to `sym.to_s.match?`; see String#match. | ||
# | ||
def match?: (Regexp | string pattern, ?int pos) -> bool | ||
def match?: (Regexp | string pattern, ?int offset) -> bool | ||
|
||
# <!-- rdoc-file=string.c --> | ||
# Equivalent to `self.to_s.succ.to_sym`: | ||
|
@@ -378,6 +374,20 @@ class Symbol | |
# | ||
def next: () -> Symbol | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
# - name -> string | ||
# --> | ||
# Returns a frozen string representation of `self` (not including the leading | ||
# colon): | ||
# | ||
# :foo.name # => "foo" | ||
# :foo.name.frozen? # => true | ||
# | ||
# Related: Symbol#to_s, Symbol#inspect. | ||
# | ||
def name: () -> String | ||
|
||
# <!-- rdoc-file=string.c --> | ||
# Equivalent to `self.to_s.length`; see String#length. | ||
# | ||
|
@@ -394,7 +404,7 @@ class Symbol | |
# --> | ||
# Equivalent to `self.to_s.start_with?`; see String#start_with?. | ||
# | ||
def start_with?: (*string | Regexp prefixes) -> bool | ||
def start_with?: (*Regexp | string prefixes) -> bool | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -445,7 +455,7 @@ class Symbol | |
# | ||
# Related: Symbol#inspect, Symbol#name. | ||
# | ||
alias to_s id2name | ||
def to_s: () -> String | ||
|
||
# <!-- | ||
# rdoc-file=symbol.rb | ||
|
@@ -455,7 +465,7 @@ class Symbol | |
# | ||
# Related: String#to_sym. | ||
# | ||
alias to_sym intern | ||
def to_sym: () -> self | ||
|
||
# <!-- | ||
# rdoc-file=string.c | ||
|
@@ -469,6 +479,4 @@ class Symbol | |
| (:ascii | :lithuanian | :turkic) -> Symbol | ||
| (:lithuanian, :turkic) -> Symbol | ||
| (:turkic, :lithuanian) -> Symbol | ||
|
||
def clone: (?freeze: true?) -> self | ||
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. Not actually defined in |
||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[Optional] Wondering if you can add a test to confirm the
_MatchAgains
generic interface works correctly with Steep. (intest/typecheck/_MatchAgainst
or somewhere.)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.
Do we have any of these as examples to base it off of?