Despite specifying JDK 1.7 in all project settings (including in File -> Project Structure -> Project :: Project SDK), the following error is produced by
[For IntelliJ IDEA 2016.2]
I would like to expand upon part of Peter Gromov's answer with an up-to-date screenshot. Specifically this particular part:
You might also want to take a look at Settings | Compiler | Java Compiler | Per-module bytecode version.
I believe that (at least in 2016.2): checking out different commits in git resets these to 1.5.