https://kotlinlang.org logo
#language-proposals
Title
# language-proposals
d

David Kubecka

03/14/2023, 1:07 PM
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

dmitriy.novozhilov

03/14/2023, 1:12 PM
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

David Kubecka

03/14/2023, 1:15 PM
Hmm, and couldn't they be friends also with respect to smart casts? 🙂
d

dmitriy.novozhilov

03/14/2023, 1:16 PM
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

David Kubecka

03/14/2023, 1:18 PM
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

dmitriy.novozhilov

03/14/2023, 1:21 PM
Interesting It worth for another ticket, indeed
d

David Kubecka

03/14/2023, 1:21 PM
Could this ^ perhaps mean that for IDEA tests and main actually constitute a single module?
d

dmitriy.novozhilov

03/14/2023, 1:22 PM
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

David Kubecka

03/14/2023, 1:25 PM
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

dmitriy.novozhilov

03/14/2023, 1:25 PM
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

David Kubecka

03/14/2023, 1:37 PM
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

dmitriy.novozhilov

03/14/2023, 1:38 PM
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

David Kubecka

03/14/2023, 1:39 PM
Ah, ok. So to which project I should report this second issue exactly? IDEA or kotlin?
d

dmitriy.novozhilov

03/14/2023, 1:40 PM
Kotlin Intellij IDEA Plugin (KTIJ)
👍 1
d

David Kubecka

03/14/2023, 2:00 PM
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

dmitriy.novozhilov

03/14/2023, 2:01 PM
Yes, that's the difference
34 Views