Exception: RBS::InvalidVarianceAnnotationError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rbs/errors.rb

Defined Under Namespace

Classes: InheritanceError, MethodTypeError, MixinError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(decl:, errors:) ⇒ InvalidVarianceAnnotationError

Returns a new instance of InvalidVarianceAnnotationError.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/rbs/errors.rb', line 165

def initialize(decl:, errors:)
  @decl = decl
  @errors = errors

  message = [
    "#{Location.to_string decl.location}: Invalid variance annotation: #{decl.name}"
  ]

  errors.each do |error|
    case error
    when MethodTypeError
      message << "  MethodTypeError (#{error.param.name}): on `#{error.method_name}` #{error.method_type.to_s} (#{error.method_type.location&.start_line})"
    when InheritanceError
      message << "  InheritanceError: #{error.super_class}"
    when MixinError
      message << "  MixinError: #{error.include_member.name} (#{error.include_member.location&.start_line})"
    end
  end

  super message.join("\n")
end

Instance Attribute Details

#declObject (readonly)

Returns the value of attribute decl.



162
163
164
# File 'lib/rbs/errors.rb', line 162

def decl
  @decl
end

#errorsObject (readonly)

Returns the value of attribute errors.



163
164
165
# File 'lib/rbs/errors.rb', line 163

def errors
  @errors
end