Skip to content

Commit

Permalink
Type#covariant? -> Type#implements?
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Mar 12, 2021
1 parent 7aa9e98 commit f2aa666
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions src/compiler/crystal/types.cr
Expand Up @@ -295,18 +295,7 @@ module Crystal
end

def covariant?(other_type : Type)
return true if self == other_type

other_type = other_type.remove_alias

case other_type
when UnionType
other_type.union_types.any? do |union_type|
covariant?(union_type)
end
else
false
end
implements?(other_type)
end

def filter_by(other_type)
Expand Down Expand Up @@ -971,10 +960,6 @@ module Crystal
end
end

def covariant?(other_type)
super || parents.any? &.covariant?(other_type)
end

def type_desc
"module"
end
Expand Down Expand Up @@ -1271,11 +1256,6 @@ module Crystal
def class?
true
end

def covariant?(other_type)
other_type = other_type.base_type if other_type.is_a?(VirtualType)
implements?(other_type) || super
end
end

# Base type for primitive types like Bool and Char.
Expand Down Expand Up @@ -1966,14 +1946,6 @@ module Crystal
super || generic_type.implements?(other_type)
end

def covariant?(other_type)
if other_type.is_a?(GenericInstanceType)
super
else
implements?(other_type)
end
end

def has_in_type_vars?(type)
type_vars.each_value do |type_var|
if type_var.is_a?(Var)
Expand Down Expand Up @@ -3003,10 +2975,6 @@ module Crystal
union_types.any? &.includes_type?(other_type)
end

def covariant?(other_type)
union_types.all? &.covariant? other_type
end

def filter_by_responds_to(name)
filtered_types = union_types.compact_map &.filter_by_responds_to(name)
program.type_merge_union_of filtered_types
Expand Down

0 comments on commit f2aa666

Please sign in to comment.