Are tests (files under `src/test` in a Maven proje...
# language-proposals
d
Are tests (files under
src/test
in a Maven project) considered to be located in a different module than
src/main
? Otherwise I cannot explain why I'm getting the
Smart cast to 'Long' is impossible, because 'XXX' is a public API property declared in different module
error in a single-module project.
d
Yes, they are different modules (but with friend relation, so you can use internals from main module in tests) From compiler point of view module is a single compilation unit -- smallest bunch of sources, which are compiled together In gradle terminology compiler modules are mapped to gradle sourcesets
d
Hmm, and couldn't they be friends also with respect to smart casts? 🙂
d
Actually yes, because test and main are always compiled together
It's better to create new issue and mention it in KT-50534 Your case is much smaller and safer (from language point of view), so it possible can be implemented separately from KT-50534
d
Ok, will do
👍 1
I guess I should also create an issue to a related problem that there's a mismatch between what kotlinc and IDEA build system think. IDEA thinks that the smart cast is actually performed in my case.
d
Interesting It worth for another ticket, indeed
d
Could this ^ perhaps mean that for IDEA tests and main actually constitute a single module?
d
Definitely not (otherwise you'll be able to see test classes in the main module) Most likely there is a bug in some module structure representation passed from IDE to the checker which reports this error
d
Btw what's the relation of this IDE checker to the kotlin compiler? I thought that they are actually same, or rather that IDE checker relies on what compiler reports. If that's so how come that such bugs are even possible?
d
This checker is implemented deeply in the compiler IDE just shows errors found by the compiler
You can easily check in IDE from where any warning/error was reported from compiler or from IDE by enabling internal mode When it enabled you will see internal diagnostic name in pop-up with message if this diagnostic was reported by compiler
^first one from ide, second one from compiler
d
I didn't know about the internal mode. Thanks!
Anyway, I still don't understand how could it be that IDE "missed" that message from the compiler (about impossible smartcast)
d
BTW you can also add
-Xrender-internal-diagnostic-names
compiler flag to render those names during build too if you want
Anyway, I still don't understand how could it be that IDE "missed" that message from the compiler (about impossible smartcast)
IDE don't loose it. It's compiler for some reason don't report it based on configuration and data passed to it from IDE
d
Ah, ok. So to which project I should report this second issue exactly? IDEA or kotlin?
d
Kotlin Intellij IDEA Plugin (KTIJ)
👍 1
d
you will see internal diagnostic name in pop-up with message if this diagnostic was reported by compiler
How can I actually see which error is coming from where? 🙂 Do compiler errors have the square brackets prefix?
d
Yes, that's the difference