newFile

private fun newFile(code: String): KtFile

An in-memory snippet. Named SCRIPT_EXT for the same reason an eval's source is: any extension but .kt is the whole of what puts the parser into script mode, which is what lets top-level statements sit beside declarations.

Its module is built here and pinned to the file rather than left to the platform, which would mint a fresh one on every analyze — and each one takes a smart pointer on the file that nothing ever hands back. An explicit module short-circuits that: the same instance is returned from then on, so a file costs one module and one pointer no matter how many queries run against it.

The file is non-physical, so the module is a dangling one, resolved against this session's context. PREFER_SELF because a snippet's own top-level declarations are part of what it means.