The key reason why we’re never going to ship something like this as an official plugin is that, as discussed in A bit about picking defaults, open by default breaks smart casts. Opening a class via a compiler plugin is even worse because it breaks smart casts silently: the compiler assumes that it can rely on a property of the code when in fact this property can be violated at runtime. In the specific set of cases supported by the kotlin-spring plugin, this is typically not an issue, but this will become an issue if we support it as a general solution.
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Kotlinc flag to switch all the classes/methods to open by default | 1 | 2981 | July 28, 2017 | |
| Classes final by default | 83 | 67891 | April 17, 2019 | |
|
How to compile Kotlin Script into open (not-final) java class?
|
0 | 840 | July 14, 2021 | |
| Spring @EventListener not opened with spring plugin!? | 7 | 245 | March 8, 2025 | |
|
Question on default final on classes and interoperation with existing cglib ecosystem
|
3 | 1472 | May 5, 2015 |