It would be nice if tools.namespace would throw an error when AOT was turned on. I recently turned on AOT for a project and unknowingly broke refresh without thinking. It was during a flurry of other changes and so it took me a while to figure that was the issue and track down that tools.namespace doesn't work with AOT. Is it possible to detect AOT inside of the clojure runtime?
"AOT turned on" doesn't have much meaning in this context. The Clojure compiler has a flag compile-files — when it is true, loading a file will also write out .class files to disk.
However, compile-files is only true while files are actually being compiled. In nearly all Clojure projects, AOT-compilation is handled in a separate step by a build tool, so compile-files is always false at runtime.
It is not the fact that AOT-compilation is enabled which is the problem: it is the fact that previously-AOT-compiled files exist on the classpath at the time a namespace is loaded, and additionally that a user tries to reload one of those namespaces at the REPL.
AOT compilation in Clojure is designed to be completely opaque to Clojure source code: it is impossible to know if a namespace has been loaded from an AOT-compiled .class file or a source .clj file.
Even if AOT-compiled .class files exist on the classpath, it is not necessarily an error. It is possible that projects with customized build processes will AOT-compile some file for Java interop or other purposes, while leaving other files to be loaded from source.