Can we write a custom syntax for Kotlin with a com...
# compiler
t
Can we write a custom syntax for Kotlin with a compiler plugin? Like union type:
type newType = typeA | typeB
?
🚫 2
r
You can hack your way into it but it’s easier to modify just typechecking for a valid shape for example:
Copy code
typealias NewType = Union<TypeA, TypeB>
val a: NewType = a // or b

val f : TypeA? = a //ok
val g : TypeB? = a //ok
val h : TypeA? = b //ok
val i : TypeB? = b //ok
val z : TypeB? = other // not ok
👍 2