You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abstract class Base(Options)
abstract def run(opts : Options)
end
class SpecificOptions
end
class Derived < Base(SpecificOptions)
def run(opts : SpecificOptions)
end
end
Derived.new.run(SpecificOptions.new)
I get this error:
Error in line 2: abstract `def Base(Options)#run(opts : Options)` must be implemented by Derived
I would have expected this to work, but maybe I'm misunderstanding something about the syntax?
The text was updated successfully, but these errors were encountered:
@RayDF pointed out on Gitter that removing the abstract keyword fixes the problem. I made a more fleshed-out example to prove to myself that polymorphism actually works correctly with the non-abstract version: https://play.crystal-lang.org/#/r/1aqj
Yes, right now the abstract check is pretty simple, it doesn't resolve generic type arguments, but the above should probably work. Workaround to make it work for now: remove the abstract method definition.
When I try to compile the following code:
I get this error:
I would have expected this to work, but maybe I'm misunderstanding something about the syntax?
The text was updated successfully, but these errors were encountered: