Fix for KT-14012: Back-end (JVM) Internal error every first compilation after the source code change
#KT-14012 Fixed
This commit is contained in:
@@ -83,6 +83,7 @@ import java.util.List;
|
|||||||
import static org.jetbrains.kotlin.codegen.AsmUtil.isStaticMethod;
|
import static org.jetbrains.kotlin.codegen.AsmUtil.isStaticMethod;
|
||||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
|
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
|
||||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.*;
|
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.*;
|
||||||
|
import static org.jetbrains.kotlin.fileClasses.JvmFileClassUtil.getPartFqNameForDeserializedCallable;
|
||||||
import static org.jetbrains.kotlin.resolve.BindingContextUtils.getDelegationConstructorCall;
|
import static org.jetbrains.kotlin.resolve.BindingContextUtils.getDelegationConstructorCall;
|
||||||
import static org.jetbrains.kotlin.resolve.BindingContextUtils.isVarCapturedInClosure;
|
import static org.jetbrains.kotlin.resolve.BindingContextUtils.isVarCapturedInClosure;
|
||||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
|
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
|
||||||
@@ -866,12 +867,8 @@ public class KotlinTypeMapper {
|
|||||||
|
|
||||||
if (DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
if (DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
||||||
if (Visibilities.isPrivate(descriptor.getVisibility()) && !(descriptor instanceof ConstructorDescriptor) && !"<clinit>".equals(name)) {
|
if (Visibilities.isPrivate(descriptor.getVisibility()) && !(descriptor instanceof ConstructorDescriptor) && !"<clinit>".equals(name)) {
|
||||||
KtFile containingFile = DescriptorToSourceUtils.getContainingFile(descriptor);
|
String partName = getPartSimpleNameForMangling(descriptor);
|
||||||
assert containingFile != null : "Private descriptor accessed outside of corresponding file scope: " + descriptor;
|
if (partName != null) return name + "$" + partName;
|
||||||
JvmFileClassInfo fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(containingFile);
|
|
||||||
if (fileClassInfo.getWithJvmMultifileClass()) {
|
|
||||||
return name + "$" + fileClassInfo.getFileClassFqName().shortName().asString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -883,6 +880,28 @@ public class KotlinTypeMapper {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String getPartSimpleNameForMangling(@NotNull CallableMemberDescriptor descriptor) {
|
||||||
|
KtFile containingFile = DescriptorToSourceUtils.getContainingFile(descriptor);
|
||||||
|
if (containingFile != null) {
|
||||||
|
JvmFileClassInfo fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(containingFile);
|
||||||
|
if (fileClassInfo.getWithJvmMultifileClass()) {
|
||||||
|
return fileClassInfo.getFileClassFqName().shortName().asString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
descriptor = getDirectMember(descriptor);
|
||||||
|
assert descriptor instanceof DeserializedCallableMemberDescriptor :
|
||||||
|
"Descriptor without sources should be instance of DeserializedCallableMemberDescriptor, but: " +
|
||||||
|
descriptor;
|
||||||
|
ContainingClassesInfo containingClassesInfo =
|
||||||
|
getContainingClassesForDeserializedCallable((DeserializedCallableMemberDescriptor) descriptor);
|
||||||
|
String facadeShortName = containingClassesInfo.getFacadeClassId().getShortClassName().asString();
|
||||||
|
String implShortName = containingClassesInfo.getImplClassId().getShortClassName().asString();
|
||||||
|
return !facadeShortName.equals(implShortName) ? implShortName : null;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Method mapAsmMethod(@NotNull FunctionDescriptor descriptor) {
|
public Method mapAsmMethod(@NotNull FunctionDescriptor descriptor) {
|
||||||
return mapSignature(descriptor, true).getAsmMethod();
|
return mapSignature(descriptor, true).getAsmMethod();
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// FILE: A.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
var property = "fail"
|
||||||
|
private set
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
property = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
test()
|
||||||
|
return property
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// FILE: A.kt
|
||||||
|
@file:JvmName("TTest")
|
||||||
|
@file:JvmMultifileClass
|
||||||
|
package test
|
||||||
|
|
||||||
|
var property = "fail"
|
||||||
|
private set
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
property = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
test()
|
||||||
|
return property
|
||||||
|
}
|
||||||
+12
@@ -149,6 +149,18 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt14012.kt")
|
||||||
|
public void testKt14012() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/kt14012.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt14012_multi.kt")
|
||||||
|
public void testKt14012_multi() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/kt14012_multi.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("multifileClassInlineFunctionAccessingProperty.kt")
|
@TestMetadata("multifileClassInlineFunctionAccessingProperty.kt")
|
||||||
public void testMultifileClassInlineFunctionAccessingProperty() throws Exception {
|
public void testMultifileClassInlineFunctionAccessingProperty() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/multifileClassInlineFunctionAccessingProperty.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/multifileClassInlineFunctionAccessingProperty.kt");
|
||||||
|
|||||||
+12
@@ -821,6 +821,18 @@ public class ExperimentalIncrementalJpsTestGenerated extends AbstractExperimenta
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("publicPropertyWithPrivateSetter")
|
||||||
|
public void testPublicPropertyWithPrivateSetter() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/publicPropertyWithPrivateSetter/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("publicPropertyWithPrivateSetterMultiFileFacade")
|
||||||
|
public void testPublicPropertyWithPrivateSetterMultiFileFacade() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/publicPropertyWithPrivateSetterMultiFileFacade/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("removeAndRestoreCompanion")
|
@TestMetadata("removeAndRestoreCompanion")
|
||||||
public void testRemoveAndRestoreCompanion() throws Exception {
|
public void testRemoveAndRestoreCompanion() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/removeAndRestoreCompanion/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/removeAndRestoreCompanion/");
|
||||||
|
|||||||
+12
@@ -821,6 +821,18 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("publicPropertyWithPrivateSetter")
|
||||||
|
public void testPublicPropertyWithPrivateSetter() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/publicPropertyWithPrivateSetter/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("publicPropertyWithPrivateSetterMultiFileFacade")
|
||||||
|
public void testPublicPropertyWithPrivateSetterMultiFileFacade() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/publicPropertyWithPrivateSetterMultiFileFacade/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("removeAndRestoreCompanion")
|
@TestMetadata("removeAndRestoreCompanion")
|
||||||
public void testRemoveAndRestoreCompanion() throws Exception {
|
public void testRemoveAndRestoreCompanion() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/removeAndRestoreCompanion/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/removeAndRestoreCompanion/");
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
================ Step #1 =================
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/test2/Prop2Kt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/prop2.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
var property = 1
|
||||||
|
private set
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package test2
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun dummy() {
|
||||||
|
if (true) 1 else property
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun dummy() {
|
||||||
|
if (true) 2 else property
|
||||||
|
}
|
||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
================ Step #1 =================
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/test2/Prop2Kt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/prop2.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
@file:JvmName("TTest")
|
||||||
|
@file:JvmMultifileClass
|
||||||
|
package test
|
||||||
|
|
||||||
|
var property = 1
|
||||||
|
private set
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package test2
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun dummy() {
|
||||||
|
if (true) 1 else property
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun dummy() {
|
||||||
|
if (true) 2 else property
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user