crystal
crystal copied to clipboard
Fix `Class#nilable?` for recursive unions and root types
Fixes #6447. Does not affect the macro method TypeNode#nilable?
. Also does not affect the compiler's notion of a nilable type (which uses instead Type#includes_type?(NilType)
).
For illustration, this is what we're talking about:
def foo(v : Value)
v.nil? # => true
end
def bar(o : Object)
o.nil? # => true
end
foo nil
bar nil
Any parent type of Nil
or Union
is nilable because it can hold a value of type Nil
.