From 510c0eff7f0735226a7c4a2461c35b1c064eb3fd Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Tue, 28 Jan 2014 12:54:24 +0400 Subject: [PATCH] Added field class checking --- .../jet/codegen/asm/InlineCodegen.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/asm/InlineCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/asm/InlineCodegen.java index a8b4e9d007d..8c0ed273756 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/asm/InlineCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/asm/InlineCodegen.java @@ -51,8 +51,8 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.util.*; - -import static org.jetbrains.jet.codegen.AsmUtil.*; +import static org.jetbrains.jet.codegen.AsmUtil.getMethodAsmFlags; +import static org.jetbrains.jet.codegen.binding.CodegenBinding.asmTypeForAnonymousClass; public class InlineCodegen implements ParentCodegenAware, Inliner { @@ -272,8 +272,20 @@ public class InlineCodegen implements ParentCodegenAware, Inliner { boolean shouldPut = false == (stackValue != null && stackValue instanceof StackValue.Local); if (shouldPut) { //we could recapture field of anonymous objects cause they couldn't change - if ((stackValue instanceof StackValue.Composed || stackValue instanceof StackValue.Field) && codegen.getContext().getContextDescriptor() instanceof AnonymousFunctionDescriptor) { - if (descriptor != null && !InlineUtil.hasNoinlineAnnotation(descriptor)) { + if (codegen.getContext().getContextDescriptor() instanceof AnonymousFunctionDescriptor) { + Type internalName = asmTypeForAnonymousClass(bindingContext, (FunctionDescriptor) codegen.getContext().getContextDescriptor()); + + String owner = null; + if (stackValue instanceof StackValue.Field) { + owner = ((StackValue.Field) stackValue).owner.getInternalName(); + } + + if (stackValue instanceof StackValue.Composed) { + //go through aload 0 + owner = internalName.getInternalName(); + } + + if (descriptor != null && !InlineUtil.hasNoinlineAnnotation(descriptor) && internalName.getInternalName().equals(owner)) { //check type of context return false; }