Exception: RBS::NoSelfTypeFoundError

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name:, location:) ⇒ NoSelfTypeFoundError

Returns a new instance of NoSelfTypeFoundError.



122
123
124
125
126
127
# File 'lib/rbs/errors.rb', line 122

def initialize(type_name:, location:)
  @type_name = type_name
  @location = location

  super "#{Location.to_string location}: Could not find self type: #{type_name}"
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



120
121
122
# File 'lib/rbs/errors.rb', line 120

def location
  @location
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



119
120
121
# File 'lib/rbs/errors.rb', line 119

def type_name
  @type_name
end

Class Method Details

.check!(self_type, env:) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/rbs/errors.rb', line 129

def self.check!(self_type, env:)
  type_name = self_type.name

  dic = case
        when type_name.class?
          env.class_decls
        when type_name.interface?
          env.interface_decls
        else
          raise
        end

  dic.key?(type_name) or raise new(type_name: type_name, location: self_type.location)
end