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¶
Methods¶
#check_return_type(target_type : Type, type : Type, method : Def, base_type : Type, base_method : Def)
¶
(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
).
#implements?(target_type : Type, t1 : Type, m1 : Def, free_vars1, t2 : Type, m2 : Def, free_vars2)
¶
(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
).
#implements?(target_type : Type, ancestor_type : Type, method : Def, base : Type, method_free_vars)
¶
(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
.
#replace_method_arg_paths_with_type_vars(base_type : Type, method : Def, generic_type : GenericInstanceType)
¶
(base_type : Type, method : Def, generic_type : GenericInstanceType)