Intriguing IntelliJ IDEA behaviour

Sometimes I type this in:

ArrayList<String> out = new ArrayList<String>();

and when I come back to the code, IDEA has replaced it with:

ArrayList<String> out = new ArrayList<~>();

Been looking for answers to this, but with no luck. Even more mysteriously, if I click over the tilde, it gets expanded back to String!

IDEA is playing games with me... ㋩