-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
superclass mismatch in overloading of a generic open class #3423
Comments
Thanks to cjgajard for letting me know of the existence of this related issue: #3298. |
@RayDF I think it's a valid issue, why did you close it? |
I'm sorry for making confusion, this is a bug by itself, but when you said: one should be able to overload/override by type, in gitter/irc, that was related to 3298 |
Reduced: class Foo(T)
end
class Bar(T) < Foo(T)
end
class Bar(T) < Foo(T)
end |
Hi @asterite : I closed because i was able to override the original behavior with this: module Test
class TestView(T) < View(T)
def render
pp outbox[:test]?.try &.as?(String).try &.upcase
end
end
end
module Test
class TestView(T)
def render
pp @outbox.class
end
end
end
But there's a need for generics specialization that would make sense in the long run :). Any other considerations on why you needed to change the compiler for taking in consideration the case?. Thanks, raydf |
@asterite , sorry, now i see the other case when you want to override the inheritance part: class TestView(T) < View2(T)
...
end Nice to know that it was a quick fix :). |
I compiled crystal>master and it doesn't allow to override the inherited parent: superclass mismatch for class Test::TestView(T) (View2(T) for View(T))
class TestView(T) < View2(T)
^ I believe this issue should be reopened. |
@RayDF You can't override a superclass, but specifying a same superclass is OK |
Well, ok, then everything works right in the master branch. |
I'm trying to overload an open class with generics. I'm receiving a superclass mismatch error, but i believe this code should be possible.
Mac OS X Sierra
Crystal 0.19.4 (2016-10-07)
The text was updated successfully, but these errors were encountered: