New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overridden == being ignored under particular circumstances #7105
Comments
I think the |
Another option here would be to include |
The |
Might be related to #6760 |
Reduced: class A
def bar(other)
1
end
end
class B
def bar(other : self)
2
end
def bar(other)
3
end
end
class C < B
def foo
A.new.as(A | C)
end
def bar(other : self)
{% @type %}
foo.bar other.foo
4
end
end
class D < C
end
def test
{% D.methods %} # => []
D.new.bar(D.new) # => 4
{% D.methods %} # => [def bar(other : self); 2; end, def bar(other); 3; end]
D.new.bar(D.new) # => 2
end
test Non-macro defs should never have to be copied to subtypes. |
Crystal is using
Reference#==
instead ofDerived#==
in the last line of the following code:Commenting out any of the sections marked One, Two, Three will cause the override for == to be used, which I believe is the correct behavior.
carc.in link: https://carc.in/#/r/5lvi
The text was updated successfully, but these errors were encountered: