lib/rbs/errors.rb in rbs-0.5.0 vs lib/rbs/errors.rb in rbs-0.6.0
- old
+ new
@@ -123,10 +123,53 @@
type_name
end
end
+ class NoSuperclassFoundError < StandardError
+ attr_reader :type_name
+ attr_reader :location
+
+ def initialize(type_name:, location:)
+ @type_name = type_name
+ @location = location
+
+ super "#{Location.to_string location}: Could not find super class: #{type_name}"
+ end
+
+ def self.check!(type_name, env:, location:)
+ env.class_decls.key?(type_name) or raise new(type_name: type_name, location: location)
+ end
+ end
+
+ class NoMixinFoundError < StandardError
+ attr_reader :type_name
+ attr_reader :member
+
+ def initialize(type_name:, member:)
+ @type_name = type_name
+ @member = member
+
+ super "#{Location.to_string location}: Could not find mixin: #{type_name}"
+ end
+
+ def location
+ member.location
+ end
+
+ def self.check!(type_name, env:, member:)
+ dic = case
+ when type_name.class?
+ env.class_decls
+ when type_name.interface?
+ env.interface_decls
+ end
+
+ dic.key?(type_name) or raise new(type_name: type_name, member: member)
+ end
+ end
+
class DuplicatedMethodDefinitionError < StandardError
attr_reader :decl
attr_reader :location
def initialize(decl:, name:, location:)
@@ -185,42 +228,17 @@
raise new(original_name: original_name, aliased_name: aliased_name, location: location)
end
end
end
- class MixedClassModuleDeclarationError < StandardError
- attr_reader :name
- attr_reader :decl
-
- def initialize(name:, decl:)
- @name = name
- @decl = decl
- super "#{Location.to_string decl.location}: Both class and module declarations: #{name}"
- end
- end
-
class SuperclassMismatchError < StandardError
attr_reader :name
attr_reader :entry
def initialize(name:, super_classes:, entry:)
@name = name
@entry = entry
super "#{Location.to_string entry.primary.decl.location}: Superclass mismatch: #{name}"
- end
- end
-
- class ModuleSelfTypeMismatchError < StandardError
- attr_reader :name
- attr_reader :entry
- attr_reader :location
-
- def initialize(name:, entry:, location:)
- @name = name
- @entry = entry
- @location = location
-
- super "#{Location.to_string location}: Module self type mismatch: #{name}"
end
end
class InconsistentMethodVisibilityError < StandardError
attr_reader :type_name