Hello, I wonder if KSP could help me show some function call as a compile time error, let me explain:
Copy code
enum class Value {
Default, Value1, Value2
}
class SomeClass(val values: List<Value>) {
fun hasValue1() = values.contains(Value.Value1)
fun hasValue2() = values.contains(Value.Value2)
}
fun main() {
val someClass = SomeClass(listOf(Value.Default, Value.Value1))
someClass.hasValue2() // how to make this call compile time error?
}
As
someClass
does not contain
Value.Value2
in its
values
property, I would like to make a call to
hasValue2
a compile time error.
Is it possible to do so?
j
Jiaxiang
11/03/2020, 8:26 PM
This does not sound like a valid use case for KSP, we don’t support expression level inspection, a compiler plugin might be more suitable