https://kotlinlang.org logo
#compiler
Title
# compiler
h

hfhbd

03/04/2024, 7:55 AM
I wrote my first IR compiler plugin, which generates init blocks for each annotated property. The init block throws an exception if the property does not pass some requirements. Everything works as expected! Surprisingly, the stacktrace of the thrown exception in the init block does not refer to some not existing Kotlin code line but to the annotation of the property. This is incredibly nice, but I want to understand, how I did this to keep this behaviour/use it somewhere else.
d

dmitriy.novozhilov

03/04/2024, 7:57 AM
Stack trace locations (together with debug information) are based on
startOffset
and
endOffset
fields, which represent offsets of the element in the source file
thank you color 1