Intellij Idea freezes when typing nested maps

Issue #1023 resolved
Oleg Malitsky created an issue

Win 10, last Idea build, last IC2.

How to reproduce: Start with nm as and try to make some nested maps. Idea will hang in third or fourth. http://prntscr.com/jrl8i9

Comments (4)

  1. Scott Wells repo owner

    Hi, Oleg. I've been unable to reproduce this myself. Could you reproduce it and then get a thread dump of the IntelliJ IDEA process? Please let me know if you're not sure how to grab a thread dump for a local Java process.

  2. Scott Wells repo owner

    Okay, I was able to reproduce this. I had misunderstood the issue originally thinking it was nested map initializers, but referring back to your screenshot, I can see that it's nested type parameters. I was able to capture the frozen state in the debugger and it's basically getting stuck trying to suggest a variable name for a map declaration that doesn't yet have one. This is because the nm live template doesn't suggest a name for the new Map variable until you tab through the key and value type parameters.

    I tried changing the live template so that it initializes with a default variable name, e.g., newMap, to see if that might avoid the issue (albeit with lowered usability for that live template IMO), but it didn't make a difference. At about the sixth or seventh nested type parameter, things either got unusably slow or locked up.

    Looking at where this is happening...in expression type evaluation which is a VERY sensitive and critical aspect of IC...I'm concerned about the risk of trying to change/optimize things in that area for this use case. How often do you find yourself needing to create such deeply-nested generic data structures like this? I assume it's to hold a raw deserialized JSON object or something?

  3. Oleg Malitsky reporter

    Hi Scott,

    I'm appreciate that you find some time to dig into this issue. I was able to find this issue accidentally, and i've never have a strong need to use such deep nested maps. Don't think that it have to be fixed if it take more than 2-4 hours or it's origin is that complex as you told in your answer :)

  4. Scott Wells repo owner

    Okay, thanks for the context. Given the niche nature of the issue and the potential complexity/risk of a fix, I'm going to resolve this until/unless it becomes a real issue for someone. Thanks again!

  5. Log in to comment