Now the implementation would accept following code:
//--- impl.cppm
module M:impl;
class A {};
//--- M.cppm
export module M;
import :impl;
//--- Use.cpp
import M;
void test() {
A a; // Expected error. A is not visible here.
}which is clearly wrong. The root cause is the implementation of isInCurrentModule would return true if the module is a partition! So in the above example, although Use.cpp is not a module unit, isInCurrentModule would still return true when the compiler tries to see if the owning module of A is the current module. I believe this is an oversight. And we could fix it simply by comparing the primary module name.
I do not understand the purpose of this change, we already iterated over making the function more efficient.
For C++20 modules there cannot be more than one parent - so that the nested call to getTopLevelModule(), via getTopLevelModuleName() is redundant.
Is there some other case that needs special handling?
(If so then I think we should guard this at a higher level)