Skip to content

class Crystal::AbstractDefChecker
inherits Reference

Checks that abstract methods are implemented.

We traverse all abstract types in the program (abstract classes/structs and modules) and for each abstract method we find, we traverse the implementors (subtypes and including types) and see if they implement that method.

An abstract method is either implemented if the type restriction (if any) matches, of if there's no type restriction. For example:

abstract class Foo
  abstract def foo(x : Int32)
end

class Bar < Foo
  # OK
  def foo(x : Int32); end
end

class Baz < Foo
  # OK too, because it's more general
  def foo(x); end
end

Class methods

.new(program : Program)

View source

Methods

#check_arg(t1 : Type, a1 : Arg, free_vars1, t2 : Type, a2 : Arg, free_vars2)

View source

#check_implemented_in_subtypes(base, type, method, free_vars)

View source

#check_implemented_in_subtypes(type, method, free_vars)

View source

#check_return_type(target_type : Type, type : Type, method : Def, base_type : Type, base_method : Def)

Checks that the return type of type#method matches that of base_type#base_method when computing that information for target_type (type is an ancestor of target_type).

View source

#check_single(type)

View source

#check_types(type)

View source

#find_base_generic_instantiation(type : Type, base_type : GenericType)

View source

#implements?(target_type : Type, t1 : Type, m1 : Def, free_vars1, t2 : Type, m2 : Def, free_vars2)

Returns true if the method t1#m1 implements t2#m2 when computing that to check whether target_type implements t2#m2 (t1 is an ancestor of target_type).

View source

#implements?(target_type : Type, ancestor_type : Type, method : Def, base : Type, method_free_vars)

Returns true if ancestor_type implements method of base when computing that information to check whether target_type implements method of base.

View source

#implements_with_ancestors?(type : Type, method : Def, base : Type, free_vars)

View source

#replace_method_arg_paths_with_type_vars(base_type : Type, method : Def, generic_type : GenericInstanceType)

View source