Don't generate default getter for object declaration property descriptor

This commit is contained in:
Mikhael Bogdanov
2013-03-14 19:35:20 +04:00
parent 5bed6c296d
commit 83a717bafe
2 changed files with 12 additions and 1 deletions
@@ -805,7 +805,7 @@ public class DescriptorResolver {
); );
propertyDescriptor.setType(getTypeForObjectDeclaration(classDescriptor), Collections.<TypeParameterDescriptor>emptyList(), propertyDescriptor.setType(getTypeForObjectDeclaration(classDescriptor), Collections.<TypeParameterDescriptor>emptyList(),
getExpectedThisObjectIfNeeded(containingDeclaration), NO_RECEIVER_PARAMETER); getExpectedThisObjectIfNeeded(containingDeclaration), NO_RECEIVER_PARAMETER);
propertyDescriptor.initialize(createDefaultGetter(propertyDescriptor), null); propertyDescriptor.initialize(null, null);
trace.record(BindingContext.OBJECT_DECLARATION_CLASS, propertyDescriptor, classDescriptor); trace.record(BindingContext.OBJECT_DECLARATION_CLASS, propertyDescriptor, classDescriptor);
JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration(); JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration();
if (nameAsDeclaration != null) { if (nameAsDeclaration != null) {
@@ -22,6 +22,9 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.descriptors.PropertyGetterDescriptor; import org.jetbrains.jet.lang.descriptors.PropertyGetterDescriptor;
import org.jetbrains.jet.lang.descriptors.PropertySetterDescriptor; import org.jetbrains.jet.lang.descriptors.PropertySetterDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.PropertyGetterDescriptorImpl;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.k2js.translate.context.TranslationContext; import org.jetbrains.k2js.translate.context.TranslationContext;
@@ -58,6 +61,14 @@ public final class KotlinPropertyAccessTranslator extends PropertyAccessTranslat
@NotNull @NotNull
public JsExpression translateAsGet(@Nullable JsExpression receiver) { public JsExpression translateAsGet(@Nullable JsExpression receiver) {
PropertyGetterDescriptor getter = propertyDescriptor.getGetter(); PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
if (getter == null) {
//TODO: Temporary hack!!! Rewrite codegen!
//Now for consistency we don't create default getter for object declaration property descriptor
PropertyGetterDescriptorImpl getterImpl = DescriptorResolver.createDefaultGetter(propertyDescriptor);
getterImpl.initialize(propertyDescriptor.getType());
((PropertyDescriptorImpl)propertyDescriptor).initialize(getterImpl, null);
getter = getterImpl;
}
assert getter != null : "Getter for kotlin properties should bot be null."; assert getter != null : "Getter for kotlin properties should bot be null.";
return callBuilderForAccessor(receiver) return callBuilderForAccessor(receiver)
.descriptor(getter) .descriptor(getter)