@NotNull public static List<FieldInfo> calculateConstructorParameters( @NotNull JetTypeMapper typeMapper, @NotNull CalculatedClosure closure, @NotNull Type ownerType) { BindingContext bindingContext = typeMapper.getBindingContext(); List<FieldInfo> args = Lists.newArrayList(); ClassDescriptor captureThis = closure.getCaptureThis(); if (captureThis != null) { Type type = typeMapper.mapType(captureThis); args.add(FieldInfo.createForHiddenField(ownerType, type, CAPTURED_THIS_FIELD)); } JetType captureReceiverType = closure.getCaptureReceiverType(); if (captureReceiverType != null) { args.add( FieldInfo.createForHiddenField( ownerType, typeMapper.mapType(captureReceiverType), CAPTURED_RECEIVER_FIELD)); } for (DeclarationDescriptor descriptor : closure.getCaptureVariables().keySet()) { if (descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) { Type sharedVarType = typeMapper.getSharedVarType(descriptor); Type type = sharedVarType != null ? sharedVarType : typeMapper.mapType((VariableDescriptor) descriptor); args.add( FieldInfo.createForHiddenField(ownerType, type, "$" + descriptor.getName().asString())); } else if (DescriptorUtils.isLocalFunction(descriptor)) { Type classType = asmTypeForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor); args.add( FieldInfo.createForHiddenField( ownerType, classType, "$" + descriptor.getName().asString())); } else if (descriptor instanceof FunctionDescriptor) { assert captureReceiverType != null; } } return args; }