With Kotlin 1.7.10 I was able to get the correct l...
# compiler
j
With Kotlin 1.7.10 I was able to get the correct line number of an inline function which is calling a log function via thread stacktrace. Previously to Kotlin 1.7+, this wasn't working, and now with Kotlin 1.7.20 it is not working anymore. Any workaround?
c
cool, i never noticed that that worked.
j
I noticed it luckily… but not sure if that was working due a bug or so
e
I think having it "work" would be a bug: the JVM doesn't support source locations coming from other files, so the only consistent thing to do is to use the source location of the file that the inline function got inlined into
https://youtrack.jetbrains.com/issue/KT-51738 the behavior you observed in 1.7.10 broke debugging
c
maybe kotlin needs sourcemaps like javascript
j
I created an issue some days ago, and I was imaging that it was being a bug too. Hope they can do a mix and get both working https://youtrack.jetbrains.com/issue/KT-54271
@ephemient what you mean about the source location?
e
JVM classfiles have a LineNumberTable attribute. it only stores line number, assuming that everything within the same class is defined in the same file (which is always true in Java)
there does exist a specification JSR-045 for adding more general source maps to the JVM, but the JVM itself doesn't use it. https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4972961
j
Thank you, I investigated about it and looks like it was proposed to be added and discarded so I have to do what you suggested about finding it manually.