Quantcast

How to ensure that nobody accidentally extends case class without having to declare every case class as final

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to ensure that nobody accidentally extends case class without having to declare every case class as final

Petr Novak
I just want that compilation fails hard whenever it detects that case class is extended. What are my options? I want to forbid that class extends case class for 2.11.8. Is it still possible in 2.12?

Is there a compiler flag?
Compiler plugin?
Static analysis plugin for maven/sbt?
Macro?

Thanks,
Petr

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to ensure that nobody accidentally extends case class without having to declare every case class as final

Rafał Krzewski
https://github.com/wartremover/wartremover has can enforce that each case class in your code is declared final: https://github.com/wartremover/wartremover/blob/latest-release/core/src/main/scala/wartremover/warts/FinalCaseClass.scala

Which satisfies the first part of your request but not the second :)

Cheers,
Rafał

W dniu środa, 8 lutego 2017 16:18:14 UTC+1 użytkownik [hidden email] napisał:
I just want that compilation fails hard whenever it detects that case class is extended. What are my options? I want to forbid that class extends case class for 2.11.8. Is it still possible in 2.12?

Is there a compiler flag?
Compiler plugin?
Static analysis plugin for maven/sbt?
Macro?

Thanks,
Petr

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...