buszi0809
05/29/2024, 7:57 AMinterface Route
sealed interface AuthRoute : Route {
@Serializable
data object Home : AuthRoute
@Serializable
data class User... : AuthRoute
}
And here I'd like to verify that classes and objects that implement Route have Serializable annotation and data modifier.
Unfortunately, I can't perform something like Konsist.scopeFromProject().classesAndObjects() and when I perform classes() + objects() the compiler will result in the first common type, which is the base type. Because of that I can't perform f.e
.withParentOf(Route::class).
That's because the structure of those interfaces (KoClassDeclaration and KoObjectDeclaration) is that they implement really granular interfaces, and don't have common base interfaces to share functionalities.
I think it could be improved, and for such cases we should be able to sum those values and perform operations on interfaces that they have in common.igor.wojda
05/29/2024, 1:17 PMclassesAndObjects() like methods as a workaround.
For this simple case you can also use an alternative way of filtering declarations by using providers (representing a certain aspect/type). This check is still limited to a single type but allows to cross this class/interface/object boundary.
Konsist
.scopeFromProduction()
.declarationsOf<KoAnnotationProvider>
.assertTrue {
// it is of type KoAnnotationProvider
it.hasAllAnnotationsOf(Serializable::class)
}igor.wojda
05/29/2024, 1:26 PMIntersection Types https://docs.scala-lang.org/scala3/reference/new-types/intersection-types.html.
Before going with classesAndObjects we have to do some spike, as perhaps there may be some Intersection Types alternatives for Kotlin