diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java index 17734da594c..ffa7fc0182a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java @@ -133,7 +133,10 @@ public class CodegenBinding { return false; } - return classDescriptor.isInner() || !(classDescriptor.getContainingDeclaration() instanceof ClassDescriptor); + DeclarationDescriptor containingDeclaration = classDescriptor.getContainingDeclaration(); + return classDescriptor.isInner() + || containingDeclaration instanceof ScriptDescriptor + || !(containingDeclaration instanceof ClassDescriptor); } @NotNull diff --git a/compiler/testData/codegen/script/kt22029.kts b/compiler/testData/codegen/script/kt22029.kts new file mode 100644 index 00000000000..179326ec8af --- /dev/null +++ b/compiler/testData/codegen/script/kt22029.kts @@ -0,0 +1,9 @@ +data class Pair(val first: Int, val second: Int) + +inline fun run(fn: () -> T) = fn() + +val fstSec = 42 + +val (fst, snd) = run { Pair(fstSec, fstSec) } + +// expected: fst: 42 \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ScriptCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ScriptCodegenTestGenerated.java index b16e14c5a91..9079bbab43b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ScriptCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ScriptCodegenTestGenerated.java @@ -73,6 +73,12 @@ public class ScriptCodegenTestGenerated extends AbstractScriptCodegenTest { doTest(fileName); } + @TestMetadata("kt22029.kts") + public void testKt22029() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/script/kt22029.kts"); + doTest(fileName); + } + @TestMetadata("localDelegatedProperty.kts") public void testLocalDelegatedProperty() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/script/localDelegatedProperty.kts");