Exception: RBS::InheritModuleError

Inherits:
DefinitionError show all
Includes:
DetailedMessageable
Defined in:
sig/errors.rbs,
lib/rbs/errors.rb

Overview

InheritModuleError is raised if a class definition inherits a module (not a class)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DetailedMessageable

#detailed_message

Constructor Details

#initialize(super_decl) ⇒ InheritModuleError

Returns a new instance of InheritModuleError.

Parameters:

  • (super_class)


192
193
194
195
196
# File 'lib/rbs/errors.rb', line 192

def initialize(super_decl)
  @super_decl = super_decl

  super "#{Location.to_string(super_decl.location)}: Cannot inherit a module: #{super_decl.name}"
end

Instance Attribute Details

#super_declsuper_class (readonly)

Returns the value of attribute super_decl.

Returns:

  • (super_class)


190
191
192
# File 'lib/rbs/errors.rb', line 190

def super_decl
  @super_decl
end

Class Method Details

.check!(super_decl, env:) ⇒ void

This method returns an undefined value.

Confirms if super inherits specifies a class

Automatically normalize the name of super.

Parameters:



325
326
327
328
329
330
# File 'sig/errors.rbs', line 325

def self.check!(super_decl, env:)
  super_name = env.normalize_type_name(super_decl.name)
  return if env.class_decl?(super_name) || env.class_alias?(super_name)

  raise new(super_decl)
end

Instance Method Details

#locationLocation[untyped, untyped]?

Returns:



198
199
200
# File 'lib/rbs/errors.rb', line 198

def location
  @super_decl.location
end