-
-
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
Variance with generic parent class #1943
Comments
IIRC, @asterite said the + was supposed to be an internal thing; you should never have to use it explicitly. |
@kirbyfan64 Good to know, thank you. I may have over-simplified my example code. Something a little closer shows why I thought including the class Parent(T); end
class Child < Parent(String); end
class Example
@value :: Parent(String)
def initialize(@value)
end
end
Example.new Child.new This results in:
This seems to be saying that |
Yes, inheriting from a generic class doesn't work pretty well :-( |
The first example works now, the second example gives a compile time error when ported to new syntax. When adding a cast it gives a compile time exception instead of a proper error message: https://carc.in/#/r/zym |
Closed in favor of #2665 |
I'm getting an unexpected error from the Crystal compiler. Here's an example:
This results in a compiler error:
The code in my example seems weird, but that's because I've simplified it to get to the essence of the problem. I'm toying around with writing a parser combinator library, and this functionality would be really useful.
If
Child
is a subclass ofParent(String)
then it seems like it should work with aParent(String)+
type restriction.The text was updated successfully, but these errors were encountered: