class
Crystal::AbstractDefChecker
Overview
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
Defined in:
compiler/crystal/semantic/abstract_def_checker.crConstructors
Instance Method Summary
- #check_arg(t1 : Type, a1 : Arg, free_vars1, t2 : Type, a2 : Arg, free_vars2)
- #check_implemented_in_subtypes(base, type, method, free_vars)
- #check_implemented_in_subtypes(type, method, free_vars)
- #check_positional_param_names(impl_method : Def, base_type : Type, base_method : Def)
-
#check_return_type(target_type : Type, type : Type, method : Def, base_type : Type, base_method : Def)
Checks that the return type of
type#methodmatches that ofbase_type#base_methodwhen computing that information fortarget_type(typeis an ancestor oftarget_type). - #check_single(type)
- #check_types(type)
- #find_base_generic_instantiation(type : Type, base_type : GenericType)
-
#implements?(target_type : Type, t1 : Type, m1 : Def, free_vars1, t2 : Type, m2 : Def, free_vars2)
Returns
trueif the methodt1#m1implementst2#m2when computing that to check whethertarget_typeimplementst2#m2(t1is an ancestor oftarget_type). -
#implements?(target_type : Type, ancestor_type : Type, method : Def, base : Type, method_free_vars)
Returns
trueifancestor_typeimplementsmethodofbasewhen computing that information to check whethertarget_typeimplementsmethodofbase. - #implements_with_ancestors?(type : Type, method : Def, base : Type, free_vars)
- #replace_method_arg_paths_with_type_vars(base_type : Type, method : Def, generic_type : GenericInstanceType)
- #run
- #same_parameters?(m1 : Def, m2 : Def)
Instance methods inherited from class Reference
==(other : self)==(other : JSON::Any)
==(other : YAML::Any)
==(other) ==, dup dup, hash(hasher) hash, initialize initialize, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, pretty_print(pp) : Nil pretty_print, same?(other : Reference) : Bool
same?(other : Nil) same?, to_s(io : IO) : Nil to_s
Constructor methods inherited from class Reference
new
new,
unsafe_construct(address : Pointer, *args, **opts) : self
unsafe_construct
Class methods inherited from class Reference
pre_initialize(address : Pointer)
pre_initialize
Instance methods inherited from class Object
! : Bool
!,
!=(other)
!=,
!~(other)
!~,
==(other)
==,
===(other : JSON::Any)===(other : YAML::Any)
===(other) ===, =~(other) =~, as(type : Class) as, as?(type : Class) as?, class class, dup dup, hash(hasher)
hash hash, in?(collection : Object) : Bool
in?(*values : Object) : Bool in?, inspect(io : IO) : Nil
inspect : String inspect, is_a?(type : Class) : Bool is_a?, itself itself, nil? : Bool nil?, not_nil!(message)
not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, responds_to?(name : Symbol) : Bool responds_to?, tap(&) tap, to_json(io : IO) : Nil
to_json : String to_json, to_pretty_json(indent : String = " ") : String
to_pretty_json(io : IO, indent : String = " ") : Nil to_pretty_json, to_s(io : IO) : Nil
to_s : String to_s, to_yaml(io : IO) : Nil
to_yaml : String to_yaml, try(&) try, unsafe_as(type : T.class) forall T unsafe_as
Class methods inherited from class Object
from_json(string_or_io : String | IO, root : String)from_json(string_or_io : String | IO) from_json, from_yaml(string_or_io : String | IO) from_yaml
Macros inherited from class Object
class_getter(*names, &block)
class_getter,
class_getter!(*names)
class_getter!,
class_getter?(*names, &block)
class_getter?,
class_property(*names, &block)
class_property,
class_property!(*names)
class_property!,
class_property?(*names, &block)
class_property?,
class_setter(*names)
class_setter,
def_clone
def_clone,
def_equals(*fields)
def_equals,
def_equals_and_hash(*fields)
def_equals_and_hash,
def_hash(*fields)
def_hash,
delegate(*methods, to object)
delegate,
forward_missing_to(delegate)
forward_missing_to,
getter(*names, &block)
getter,
getter!(*names)
getter!,
getter?(*names, &block)
getter?,
property(*names, &block)
property,
property!(*names)
property!,
property?(*names, &block)
property?,
setter(*names)
setter
Constructor Detail
Instance Method Detail
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).
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).
Returns true if ancestor_type implements method of base when computing
that information to check whether target_type implements method of base.