diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java index e251cf01723..5d22a8f160f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java @@ -379,17 +379,6 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { KotlinType delegateType = JvmCodegenUtil.getPropertyDelegateType(variableDescriptor, bindingContext); if (delegateType == null) return; - LocalVariableDescriptor delegateVariableDescriptor = new LocalVariableDescriptor( - variableDescriptor.getContainingDeclaration(), - Annotations.Companion.getEMPTY(), - variableDescriptor.getName(), - delegateType, - false, - false, - SourceElement.NO_SOURCE - ); - bindingTrace.record(LOCAL_VARIABLE_DELEGATE, variableDescriptor, delegateVariableDescriptor); - LocalVariableDescriptor metadataVariableDescriptor = new LocalVariableDescriptor( variableDescriptor.getContainingDeclaration(), Annotations.Companion.getEMPTY(), 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 16ec7abc990..957fffbc298 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java @@ -60,9 +60,6 @@ public class CodegenBinding { public static final WritableSlice> MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE = Slices.createSimpleSlice(); - public static final WritableSlice LOCAL_VARIABLE_DELEGATE = - Slices.createSimpleSlice(); - public static final WritableSlice LOCAL_VARIABLE_PROPERTY_METADATA = Slices.createSimpleSlice(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java index f3ddd692d0b..05990fdfe3a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java @@ -55,9 +55,12 @@ public interface LocalLookup { boolean idx = localLookup != null && localLookup.lookupLocal(vd); if (!idx) return null; - VariableDescriptor delegateVariableDescriptor = state.getBindingContext().get(LOCAL_VARIABLE_DELEGATE, vd); + KotlinType delegateType = + vd instanceof VariableDescriptorWithAccessors + ? JvmCodegenUtil.getPropertyDelegateType((VariableDescriptorWithAccessors) vd, state.getBindingContext()) + : null; Type sharedVarType = state.getTypeMapper().getSharedVarType(vd); - Type localType = state.getTypeMapper().mapType(delegateVariableDescriptor != null ? delegateVariableDescriptor : vd); + Type localType = state.getTypeMapper().mapType(delegateType != null ? delegateType : vd.getType()); Type type = sharedVarType != null ? sharedVarType : localType; String fieldName = "$" + vd.getName(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java index e010c2683d5..4a206ee7170 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java @@ -1392,11 +1392,11 @@ public class KotlinTypeMapper { Type sharedVarType = getSharedVarType(variableDescriptor); if (sharedVarType == null) { if (isDelegatedLocalVariable(variableDescriptor)) { - VariableDescriptor delegateVariableDescriptor = bindingContext.get(LOCAL_VARIABLE_DELEGATE, - (VariableDescriptor) variableDescriptor); - assert delegateVariableDescriptor != null : - "Local delegated property " + variableDescriptor + " delegate descriptor should be not null"; - sharedVarType = mapType(delegateVariableDescriptor.getType()); + //noinspection CastConflictsWithInstanceof + KotlinType delegateType = + JvmCodegenUtil.getPropertyDelegateType((LocalVariableDescriptor) variableDescriptor, bindingContext); + assert delegateType != null : "Local delegated property type should not be null: " + variableDescriptor; + sharedVarType = mapType(delegateType); } else { sharedVarType = mapType(((VariableDescriptor) variableDescriptor).getType());