Crystal supports user-defined annotations. This shard leverages this capability to add certain annotations.
Annotations supported include:
Final: Marks a type or method as final. Final types cannot be inheritted, final methods cannot be overridden.
Override: Marks a method as overriding an existing method in it's super class. This means a mistyped method name in the subclass gives a compile-time error, instead of being silently added as a new method.
Add this to your application's
dependencies: annotation: github: grottopress/crystal-annotation
require "annotation" # 'Final' class @[Final] class Parent end class Child < Parent # Oops! Cannot inherit final type 'Parent' end # 'Final' method class Parent @[Final] def final_method end end class Child < Parent def final_method # Oops! Cannot override final method 'final_method' end end # 'Override' class Parent def my_method end end class Child < Parent @[Override] def non_existent # Oops! Trying to override non-existent method 'non_exitent' end @[Override] def my_method # Good to go! end end
Kindly report suspected security vulnerabilities in private, via contact details outlined in this repository's
- Fork it (https://github.com/grottopress/crystal-annotation/fork)
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request