JVM IR: sort multifile part names in metadata
This commit is contained in:
Generated
+10
@@ -18481,6 +18481,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/multifileClasses/multifileClassWithPrivate.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/multifileClassWithPrivate.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("namesInMetadataAreSorted.kt")
|
||||||
|
public void testNamesInMetadataAreSorted() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multifileClasses/namesInMetadataAreSorted.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateConstVal.kt")
|
@TestMetadata("privateConstVal.kt")
|
||||||
public void testPrivateConstVal() throws Exception {
|
public void testPrivateConstVal() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multifileClasses/privateConstVal.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/privateConstVal.kt");
|
||||||
@@ -18553,6 +18558,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/internalFunction.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/internalFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("namesInMetadataAreSorted.kt")
|
||||||
|
public void testNamesInMetadataAreSorted() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/namesInMetadataAreSorted.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overlappingFuns.kt")
|
@TestMetadata("overlappingFuns.kt")
|
||||||
public void testOverlappingFuns() throws Exception {
|
public void testOverlappingFuns() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
||||||
|
|||||||
+4
-4
@@ -91,7 +91,8 @@ private fun generateMultifileFacades(
|
|||||||
shouldGeneratePartHierarchy: Boolean,
|
shouldGeneratePartHierarchy: Boolean,
|
||||||
functionDelegates: MutableMap<IrSimpleFunction, IrSimpleFunction>
|
functionDelegates: MutableMap<IrSimpleFunction, IrSimpleFunction>
|
||||||
): List<IrFile> =
|
): List<IrFile> =
|
||||||
context.multifileFacadesToAdd.map { (jvmClassName, partClasses) ->
|
context.multifileFacadesToAdd.map { (jvmClassName, unsortedPartClasses) ->
|
||||||
|
val partClasses = unsortedPartClasses.sortedBy(IrClass::name)
|
||||||
val kotlinPackageFqName = partClasses.first().fqNameWhenAvailable!!.parent()
|
val kotlinPackageFqName = partClasses.first().fqNameWhenAvailable!!.parent()
|
||||||
if (!partClasses.all { it.fqNameWhenAvailable!!.parent() == kotlinPackageFqName }) {
|
if (!partClasses.all { it.fqNameWhenAvailable!!.parent() == kotlinPackageFqName }) {
|
||||||
throw UnsupportedOperationException(
|
throw UnsupportedOperationException(
|
||||||
@@ -120,7 +121,7 @@ private fun generateMultifileFacades(
|
|||||||
}
|
}
|
||||||
if (shouldGeneratePartHierarchy) {
|
if (shouldGeneratePartHierarchy) {
|
||||||
val superClass = modifyMultifilePartsForHierarchy(context, partClasses)
|
val superClass = modifyMultifilePartsForHierarchy(context, partClasses)
|
||||||
superTypes += superClass.typeWith()
|
superTypes = listOf(superClass.typeWith())
|
||||||
|
|
||||||
addConstructor {
|
addConstructor {
|
||||||
visibility = DescriptorVisibilities.PRIVATE
|
visibility = DescriptorVisibilities.PRIVATE
|
||||||
@@ -157,8 +158,7 @@ private fun generateMultifileFacades(
|
|||||||
|
|
||||||
// Changes supertypes of multifile part classes so that they inherit from each other, and returns the last part class.
|
// Changes supertypes of multifile part classes so that they inherit from each other, and returns the last part class.
|
||||||
// The multifile facade should inherit from that part class.
|
// The multifile facade should inherit from that part class.
|
||||||
private fun modifyMultifilePartsForHierarchy(context: JvmBackendContext, unsortedParts: List<IrClass>): IrClass {
|
private fun modifyMultifilePartsForHierarchy(context: JvmBackendContext, parts: List<IrClass>): IrClass {
|
||||||
val parts = unsortedParts.sortedBy(IrClass::name)
|
|
||||||
val superClasses = listOf(context.irBuiltIns.anyClass.owner) + parts.subList(0, parts.size - 1)
|
val superClasses = listOf(context.irBuiltIns.anyClass.owner) + parts.subList(0, parts.size - 1)
|
||||||
|
|
||||||
for ((klass, superClass) in parts.zip(superClasses)) {
|
for ((klass, superClass) in parts.zip(superClasses)) {
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// FILE: ccc.kt
|
||||||
|
|
||||||
|
@file:JvmName("Facade")
|
||||||
|
@file:JvmMultifileClass
|
||||||
|
package test
|
||||||
|
fun ccc() {}
|
||||||
|
|
||||||
|
// FILE: aaa.kt
|
||||||
|
|
||||||
|
@file:JvmName("Facade")
|
||||||
|
@file:JvmMultifileClass
|
||||||
|
package test
|
||||||
|
fun aaa() {}
|
||||||
|
|
||||||
|
// FILE: _b.kt
|
||||||
|
|
||||||
|
@file:JvmName("Facade")
|
||||||
|
@file:JvmMultifileClass
|
||||||
|
package test
|
||||||
|
fun b() {}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val names = Class.forName("test.Facade").getAnnotation(Metadata::class.java).data1.toList()
|
||||||
|
return if (names == listOf("test/Facade__AaaKt", "test/Facade__CccKt", "test/Facade___bKt")) "OK" else "Fail: $names"
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// IGNORE_LIGHT_ANALYSIS
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// !INHERIT_MULTIFILE_PARTS
|
||||||
|
// FILE: ccc.kt
|
||||||
|
|
||||||
|
@file:JvmName("Facade")
|
||||||
|
@file:JvmMultifileClass
|
||||||
|
package test
|
||||||
|
fun ccc() {}
|
||||||
|
|
||||||
|
// FILE: aaa.kt
|
||||||
|
|
||||||
|
@file:JvmName("Facade")
|
||||||
|
@file:JvmMultifileClass
|
||||||
|
package test
|
||||||
|
fun aaa() {}
|
||||||
|
|
||||||
|
// FILE: _b.kt
|
||||||
|
|
||||||
|
@file:JvmName("Facade")
|
||||||
|
@file:JvmMultifileClass
|
||||||
|
package test
|
||||||
|
fun b() {}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val names = Class.forName("test.Facade").getAnnotation(Metadata::class.java).data1.toList()
|
||||||
|
return if (names == listOf("test/Facade__AaaKt", "test/Facade__CccKt", "test/Facade___bKt")) "OK" else "Fail: $names"
|
||||||
|
}
|
||||||
+10
@@ -19876,6 +19876,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/multifileClasses/multifileClassWithPrivate.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/multifileClassWithPrivate.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("namesInMetadataAreSorted.kt")
|
||||||
|
public void testNamesInMetadataAreSorted() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multifileClasses/namesInMetadataAreSorted.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateConstVal.kt")
|
@TestMetadata("privateConstVal.kt")
|
||||||
public void testPrivateConstVal() throws Exception {
|
public void testPrivateConstVal() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multifileClasses/privateConstVal.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/privateConstVal.kt");
|
||||||
@@ -19948,6 +19953,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/internalFunction.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/internalFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("namesInMetadataAreSorted.kt")
|
||||||
|
public void testNamesInMetadataAreSorted() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/namesInMetadataAreSorted.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overlappingFuns.kt")
|
@TestMetadata("overlappingFuns.kt")
|
||||||
public void testOverlappingFuns() throws Exception {
|
public void testOverlappingFuns() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
||||||
|
|||||||
+10
@@ -19876,6 +19876,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/multifileClasses/multifileClassWithPrivate.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/multifileClassWithPrivate.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("namesInMetadataAreSorted.kt")
|
||||||
|
public void testNamesInMetadataAreSorted() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multifileClasses/namesInMetadataAreSorted.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateConstVal.kt")
|
@TestMetadata("privateConstVal.kt")
|
||||||
public void testPrivateConstVal() throws Exception {
|
public void testPrivateConstVal() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multifileClasses/privateConstVal.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/privateConstVal.kt");
|
||||||
@@ -19948,6 +19953,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/internalFunction.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/internalFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("namesInMetadataAreSorted.kt")
|
||||||
|
public void testNamesInMetadataAreSorted() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/namesInMetadataAreSorted.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overlappingFuns.kt")
|
@TestMetadata("overlappingFuns.kt")
|
||||||
public void testOverlappingFuns() throws Exception {
|
public void testOverlappingFuns() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
||||||
|
|||||||
+10
@@ -18481,6 +18481,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/multifileClasses/multifileClassWithPrivate.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/multifileClassWithPrivate.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("namesInMetadataAreSorted.kt")
|
||||||
|
public void testNamesInMetadataAreSorted() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multifileClasses/namesInMetadataAreSorted.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateConstVal.kt")
|
@TestMetadata("privateConstVal.kt")
|
||||||
public void testPrivateConstVal() throws Exception {
|
public void testPrivateConstVal() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multifileClasses/privateConstVal.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/privateConstVal.kt");
|
||||||
@@ -18553,6 +18558,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/internalFunction.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/internalFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("namesInMetadataAreSorted.kt")
|
||||||
|
public void testNamesInMetadataAreSorted() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/namesInMetadataAreSorted.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overlappingFuns.kt")
|
@TestMetadata("overlappingFuns.kt")
|
||||||
public void testOverlappingFuns() throws Exception {
|
public void testOverlappingFuns() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user