diff --git a/compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt b/compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt new file mode 100644 index 00000000000..aa9e6933b1e --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt @@ -0,0 +1,53 @@ +// FILE: test.kt +// WITH_RUNTIME +// WITH_COROUTINES + +var result = "Fail" + +fun use(token: String) { + result = token +} + +inline fun f(crossinline body: suspend () -> Unit) = + g< + Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, + Any, Any, Any, Any, Any, Any, Any, Any, Any, Any, + >(body) + +inline fun < + reified U01, reified U02, reified U03, reified U04, reified U05, reified U06, reified U07, reified U08, reified U09, reified U10, + reified U11, reified U12, reified U13, reified U14, reified U15, reified U16, reified U17, reified U18, reified U19, reified U20, +> g(crossinline body: suspend () -> Unit): suspend () -> Unit { + return run { + run { + run { + run { + run { + run { + run { + run { + suspend { + body() + } + } + } + } + } + } + } + } + } +} + +// FILE: box.kt + +import kotlin.coroutines.* +import helpers.* + +fun box(): String { + var token = "OK" + f { + use(token) + }.startCoroutine(EmptyContinuation) + return result +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 4e622d6d24e..73a553a9c9f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -231,6 +231,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/anonymousObject/kt34656.kt"); } + @TestMetadata("kt38197.kt") + public void testKt38197() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt"); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index e790a47aacc..2ce3e8aa158 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -231,6 +231,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/anonymousObject/kt34656.kt"); } + @TestMetadata("kt38197.kt") + public void testKt38197() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt"); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index faac3b839a0..0b59675bd1d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -231,6 +231,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/anonymousObject/kt34656.kt"); } + @TestMetadata("kt38197.kt") + public void testKt38197() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt"); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index eaff72b2f2e..8ef212481de 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -231,6 +231,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/anonymousObject/kt34656.kt"); } + @TestMetadata("kt38197.kt") + public void testKt38197() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt"); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt"); diff --git a/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/deserialization/JvmNameResolver.kt b/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/deserialization/JvmNameResolver.kt index c32956b425a..45dfe1d8ea3 100644 --- a/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/deserialization/JvmNameResolver.kt +++ b/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/deserialization/JvmNameResolver.kt @@ -17,7 +17,9 @@ class JvmNameResolver( private val localNameIndices = types.localNameList.run { if (isEmpty()) emptySet() else toSet() } // Here we expand the 'range' field of the Record message for simplicity to a list of records - val records: List = ArrayList().apply { + // Note that as an optimization, range of each expanded record is equal to the original range, not 1. If correct ranges are needed, + // please use the original record representation in [types.recordList]. + private val records: List = ArrayList().apply { val records = types.recordList this.ensureCapacity(records.size) for (record in records) { diff --git a/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/serialization/JvmStringTable.kt b/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/serialization/JvmStringTable.kt index e3c23da8943..d9676c752b8 100644 --- a/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/serialization/JvmStringTable.kt +++ b/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/serialization/JvmStringTable.kt @@ -21,7 +21,7 @@ open class JvmStringTable(nameResolver: JvmNameResolver? = null) : StringTable { init { if (nameResolver != null) { strings.addAll(nameResolver.strings) - nameResolver.records.mapTo(records, JvmProtoBuf.StringTableTypes.Record::toBuilder) + nameResolver.types.recordList.mapTo(records, JvmProtoBuf.StringTableTypes.Record::toBuilder) for (index in strings.indices) { map[nameResolver.getString(index)] = index } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index 80146d5aaff..5407aa19ab8 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -211,6 +211,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/anonymousObject/kt34656.kt"); } + @TestMetadata("kt38197.kt") + public void testKt38197() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt"); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index c23330608b4..03c76845928 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -211,6 +211,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/anonymousObject/kt34656.kt"); } + @TestMetadata("kt38197.kt") + public void testKt38197() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt"); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");