Skip to content

Commit

Permalink
NodePattern: Avoid SimpleDelegator
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Jul 14, 2020
1 parent 160b5f5 commit 34798ca
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/rubocop/ast/node_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,15 @@ def parse_repetition_token
# @private
# Builds Ruby code for a sequence
# (head *first_terms variadic_term *last_terms)
class Sequence < SimpleDelegator
class Sequence
extend Forwardable
def_delegators :@compiler, :compile_guard_clause, :with_seq_head_context,
:with_child_context, :fail_due_to

def initialize(compiler, *arity_term_list)
@arities, @terms = arity_term_list.transpose

super(compiler)
@compiler = compiler
@variadic_index = @arities.find_index { |a| a.is_a?(Range) }
fail_due_to 'multiple variable patterns in same sequence' \
if @variadic_index && !@arities.one? { |a| a.is_a?(Range) }
Expand Down

0 comments on commit 34798ca

Please sign in to comment.