Fixed package proto for circular dependencies. Case when package is present in different modules which depend on each other. We should generate separate package facades for this case.
This commit is contained in:
@@ -25,6 +25,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.Mutable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -248,7 +249,7 @@ public class PackageCodegen {
|
||||
}
|
||||
|
||||
bindings.add(v.getSerializationBindings());
|
||||
writeKotlinPackageAnnotationIfNeeded(JvmSerializationBindings.union(bindings));
|
||||
writeKotlinPackageAnnotationIfNeeded(JvmSerializationBindings.union(bindings), tasks.keySet());
|
||||
}
|
||||
|
||||
private void generateKotlinPackageReflectionField() {
|
||||
@@ -260,7 +261,10 @@ public class PackageCodegen {
|
||||
FunctionCodegen.endVisit(mv, "package facade static initializer", null);
|
||||
}
|
||||
|
||||
private void writeKotlinPackageAnnotationIfNeeded(@NotNull JvmSerializationBindings bindings) {
|
||||
private void writeKotlinPackageAnnotationIfNeeded(
|
||||
@NotNull JvmSerializationBindings bindings,
|
||||
@NotNull final Collection<CallableMemberDescriptor> relevantCallables
|
||||
) {
|
||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) {
|
||||
return;
|
||||
}
|
||||
@@ -274,7 +278,12 @@ public class PackageCodegen {
|
||||
Collection<PackageFragmentDescriptor> packageFragments = Lists.newArrayList();
|
||||
ContainerUtil.addIfNotNull(packageFragments, packageFragment);
|
||||
ContainerUtil.addIfNotNull(packageFragments, compiledPackageFragment);
|
||||
ProtoBuf.Package packageProto = serializer.packageProto(packageFragments).build();
|
||||
ProtoBuf.Package packageProto = serializer.packageProto(packageFragments, new Function1<DeclarationDescriptor, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(DeclarationDescriptor descriptor) {
|
||||
return !(descriptor instanceof CallableMemberDescriptor && relevantCallables.contains(descriptor));
|
||||
}
|
||||
}).build();
|
||||
|
||||
if (packageProto.getMemberCount() == 0) return;
|
||||
|
||||
|
||||
@@ -43,6 +43,12 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("circularDependencySamePackageUnchanged")
|
||||
public void testCircularDependencySamePackageUnchanged() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/circularDependencySamePackageUnchanged/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("circularDependencyTopLevelFunctions")
|
||||
public void testCircularDependencyTopLevelFunctions() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/circularDependencyTopLevelFunctions/");
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
Cleaning output files:
|
||||
out/production/module1/test/TestPackage$module1_a$*.class
|
||||
out/production/module1/test/TestPackage.class
|
||||
End of files
|
||||
Compiling files:
|
||||
module1/src/module1_a.kt
|
||||
End of files
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
module1->module2
|
||||
module2->module1
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
fun a() {
|
||||
|
||||
}
|
||||
|
||||
val a = ""
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
fun a() {
|
||||
|
||||
}
|
||||
|
||||
val a = ""
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
fun b() {
|
||||
|
||||
}
|
||||
|
||||
var b = b()
|
||||
Reference in New Issue
Block a user