Has anyone experienced this weird behaviour - the ...
# intellij
v
Has anyone experienced this weird behaviour - the
first {}
function fails with the
NoSuchElementException
and the stacktrace the IDEA is showing is pointing to a line number that doesn’t exist in the file. I.e., there are 150 lines of code in the file, but stacktrace is pointing to something like
MyClass.kt:245
m
I've experienced problems with inline functions and the line numbers on stack traces. I often have to go down the stack trace until I get to the function that called
first
.
a
I believe you can do this to help you find the exact line: • Copy the stack trace output • Open the “Analyze Stack Trace” in IntelliJ (“Code” menu “Analyze Stack Trace or Thread Dump”) and paste it there (it will probably automatically paste it for you) • You’ll see what it does. 🙂
Also, if you see the exception during development inside of intellij you should be given the option to go to the actual inlined code when you click on the local file in the debugger output:
v
@Alan B that’s not what I meant. I get the stacktrace inside IntelliJ and the line number it is pointing to doesn’t exist in the file
a
So neither of those approaches work? That’s odd. I know the issue you are seeing, and those two options have worked for me, but I haven’t run into needing to the analyzer as I haven’t run into a remote stack trace debugging situation in a bit.
Have you figured out a way to create a minimal test case that can be easily replicated?
v
@Alan B again, the issue is not with the remote stacktrace. I never said it’s with remote stacktrace. My issue is happening when I run the test within the IDEA
a
I said there were two options, one was local the other was remote (just meaning not “in process” for intelliJ). I am unable to provide more info. Yes, it’s very easy to have stack traces that don’t line up with the source when using inline functions. But, normally the IDE has clickable options in the stack trace to take you to the call site. Are you running the latest version? I have you figured out an example others can run? A simple 4 line example like this:
Copy code
private inline fun filter(x: String): Boolean = throw UnknownError()
fun main() {
  listOf("a").filter(::filter)
}
Will print out:
Copy code
Exception in thread "main" java.lang.UnknownError
	at InlineThrowKt.main(InlineThrow.kt:7)
	at InlineThrowKt.main(InlineThrow.kt)
And we know there is no line 7. But the IDE usually does this with the option to click the odd line number which gives an option:
image.png
I was also asking that if you were to copy that stack trace and paste it into the analyzer, what would happen?
Results in the clickable line which gives the option to go to the body or the call site.: