Skip to content
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

Bump Sorbet version and introduce AbstractParam #160

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ GEM
rubocop-sorbet (0.7.0)
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
sorbet (0.5.10741)
sorbet-static (= 0.5.10741)
sorbet-runtime (0.5.10741)
sorbet-static (0.5.10741-universal-darwin-21)
sorbet-static (0.5.10741-x86_64-linux)
sorbet-static-and-runtime (0.5.10741)
sorbet (= 0.5.10741)
sorbet-runtime (= 0.5.10741)
sorbet (0.5.10746)
sorbet-static (= 0.5.10746)
sorbet-runtime (0.5.10746)
sorbet-static (0.5.10746-universal-darwin-21)
sorbet-static (0.5.10746-x86_64-linux)
sorbet-static-and-runtime (0.5.10746)
sorbet (= 0.5.10746)
sorbet-runtime (= 0.5.10746)
spoom (1.2.1)
sorbet (>= 0.5.10187)
sorbet-runtime (>= 0.5.9204)
Expand Down
26 changes: 15 additions & 11 deletions lib/rbi/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ class Method < NodeWithComments
sig { returns(String) }
attr_accessor :name

sig { returns(T::Array[Param]) }
sig { returns(T::Array[AbstractParam]) }
attr_reader :params

sig { returns(T::Boolean) }
Expand All @@ -501,7 +501,7 @@ class Method < NodeWithComments
sig do
params(
name: String,
params: T::Array[Param],
params: T::Array[AbstractParam],
is_singleton: T::Boolean,
visibility: Visibility,
sigs: T::Array[Sig],
Expand Down Expand Up @@ -529,7 +529,7 @@ def initialize(
block&.call(self)
end

sig { params(param: Param).void }
sig { params(param: AbstractParam).void }
def <<(param)
@params << param
end
Expand All @@ -549,7 +549,7 @@ def to_s
end
end

class Param < NodeWithComments
class AbstractParam < NodeWithComments
extend T::Helpers
extend T::Sig

Expand All @@ -576,7 +576,11 @@ def to_s
end
end

class ReqParam < Param
class Param < AbstractParam
extend T::Sig
end

class ReqParam < AbstractParam
extend T::Sig

sig do
Expand All @@ -598,7 +602,7 @@ def ==(other)
end
end

class OptParam < Param
class OptParam < AbstractParam
extend T::Sig

sig { returns(String) }
Expand All @@ -625,7 +629,7 @@ def ==(other)
end
end

class RestParam < Param
class RestParam < AbstractParam
extend T::Sig

sig do
Expand All @@ -652,7 +656,7 @@ def ==(other)
end
end

class KwParam < Param
class KwParam < AbstractParam
extend T::Sig

sig do
Expand All @@ -679,7 +683,7 @@ def ==(other)
end
end

class KwOptParam < Param
class KwOptParam < AbstractParam
extend T::Sig

sig { returns(String) }
Expand Down Expand Up @@ -711,7 +715,7 @@ def ==(other)
end
end

class KwRestParam < Param
class KwRestParam < AbstractParam
extend T::Sig

sig do
Expand All @@ -738,7 +742,7 @@ def ==(other)
end
end

class BlockParam < Param
class BlockParam < AbstractParam
extend T::Sig

sig do
Expand Down
2 changes: 1 addition & 1 deletion lib/rbi/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def parse_def(node)
end
end

sig { params(node: AST::Node).returns(Param) }
sig { params(node: AST::Node).returns(AbstractParam) }
def parse_param(node)
name = node.children[0].to_s
loc = node_loc(node)
Expand Down
6 changes: 5 additions & 1 deletion lib/rbi/printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def inline_params?
end
end

class Param
class AbstractParam
extend T::Sig

sig { override.params(v: Printer).void }
Expand All @@ -461,6 +461,10 @@ def comments_lines
end
end

class Param
extend T::Sig
end

class OptParam
extend T::Sig

Expand Down