As far as I know, Intellij IDEA creates his own memory structure to represent the actual state of the parsed files, up to a representation that enables all the useful features you get from the IDE (references, usages, docs, squiggles for compiler errors, ...).
This model is not the output of the sbt build. The plugin allows the IDE to create such in-memory representation based on the sbt build-file, and lately, using the sbt engine itself (you need to enable it in the preferences).
Still sbt doesn't allow to keep a memory representation of the output that the IDE can use, hence IDEA's "picture" of the code will sometime diverge from the real compilation output, possibly because some advanced feature in the language and plugins (macros tend to do this for example) are not correctly represented in the IDEA data structure.
Usually when you change something in the build file, IDEA auto-refreshes the build state, or prompts you to do it (when the build file editor is in focus). This should be enough to "align" the build with the IDE.
Yet there are many cases where a complex codebase can permanently show false errors in the IDE.
Right as we speak, there are many ongoing efforts to fix this situation
- a scala LSP implementation is in the making that will actually connect with the underlying build tool to provide useful information to any compatible editor (any LSP client)
- complementary to the LSP effort there's a BSP (build server protocol) being explored, whose definition should allow different compliant build tools (sbt, mill, cbt, ...) to better integrate with the underlying compiler and different editors
You can find more information on the Scala Blog Announcement