private void initializeProperty( @NotNull ExpressionCodegen codegen, @NotNull JetProperty property) { PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property); assert propertyDescriptor != null; JetExpression initializer = property.getDelegateExpressionOrInitializer(); assert initializer != null : "shouldInitializeProperty must return false if initializer is null"; JetType jetType = getPropertyOrDelegateType(property, propertyDescriptor); StackValue.Property propValue = codegen.intermediateValueForProperty( propertyDescriptor, true, null, MethodKind.INITIALIZER); if (!propValue.isStatic) { codegen.v.load(0, OBJECT_TYPE); } Type type = codegen.expressionType(initializer); if (jetType.isNullable()) { type = boxType(type); } codegen.gen(initializer, type); propValue.store(type, codegen.v); }
private boolean shouldInitializeProperty(@NotNull JetProperty property) { JetExpression initializer = property.getDelegateExpressionOrInitializer(); if (initializer == null) return false; PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property); assert propertyDescriptor != null; CompileTimeConstant<?> compileTimeValue = propertyDescriptor.getCompileTimeInitializer(); if (compileTimeValue == null) return true; // TODO: OPTIMIZATION: don't initialize static final fields Object value = compileTimeValue.getValue(); JetType jetType = getPropertyOrDelegateType(property, propertyDescriptor); Type type = typeMapper.mapType(jetType); return !skipDefaultValue(propertyDescriptor, value, type); }