[KLIB] Fix deserialization of anonymous classes

In case of initializing property or function with anonymous object the
object is being exposed outside its field/function's scope and
accessible on previous level. In this case in `declarations only` mode
we have unbound symbols. Fix is to force body/initializer loading in
such cases.

Make sure it is deserialized in `declarations'only` mode too.

 - Fix KT-40216
 - Add test
This commit is contained in:
Roman Artemev
2020-07-14 16:41:27 +03:00
committed by romanart
parent d31de6c8de
commit cd9f59325e
9 changed files with 166 additions and 15 deletions
@@ -15820,6 +15820,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("anonymousClassLeak.kt")
public void testAnonymousClassLeak() throws Exception {
runTest("compiler/testData/codegen/box/ir/anonymousClassLeak.kt");
}
@TestMetadata("anonymousObjectInForLoopIteratorAndBody.kt")
public void testAnonymousObjectInForLoopIteratorAndBody() throws Exception {
runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt");